Solved

jQuery Canlendar click function

Posted on 2016-11-19
5
22 Views
Last Modified: 2016-11-23
I am using a Wordpress Plugin called bookly.  It is at the very bottom of the page.  If you go there and click on a date, the next step appears and you can choose a time.

However, if you go to the calendar when you first load the page, then navigate to the next month and click on the calendar date, the next step does not happen.
http://0c8.88c.myftpupload (DOT) com/

This is what controls it showing.
<script>
var int = setInterval(function() {
    if ($('#footer-calendar').find('.picker__day').length > 0) {
        clearInterval(int);
        init_calendar();
    }
}, 100);

function init_calendar() {
    $('.picker__day').on("click", function(e) {
        $('#footer-calendar').addClass('calendarstart');
    });

}

Open in new window

0
Comment
Question by:rgranlund
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 41894717
work for me... desktop and mobile...
question incomplete ?
desktopmobile
0
 
LVL 16

Expert Comment

by:SSupreme
ID: 41894870
No, it doesn't, if you at first switch month (to December from November), after that times div not receiving  display:block rule.
0
 
LVL 16

Expert Comment

by:SSupreme
ID: 41894874
It is something to do with this part: wp-content/themes/inspyrus/library/js/scripts.js
function init_calendar() {
    $('.picker__table').on("click", function(e) {
        $('#footer-calendar').addClass('calendarstart');
    });

}

    $('.picker__table').on("click", function(e) {
        $('#footer-calendar').addClass('calendarstart');
    });

Open in new window

For some reason it doesn't work after you change month. Sorry, need to go.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 41895097
your datetime picker disable the propagation of the click event.
some solution :
1 - hack/fix it so it don't stop propagation on click
2 - register click event before it, so you got first the click
3 - replace your current code (what you post in the code snippet) by the following.
We use mouseup instead click event. Bonus, we handle touchstart too

<script>
function init_calendar(evt) {
	if($(evt.target).hasClass("picker__day"))
             $('#footer-calendar').addClass('calendarstart');
}

if(document.addEventListener) {
	document.addEventListener("touchstart", init_calendar, false);
	document.addEventListener("mouseup", init_calendar, false);
}
else {
	document.attachEvent("ontouchstart", init_calendar);
	document.attachEvent("onmouseup", init_calendar);
}

Open in new window


work in december
0
 
LVL 82

Expert Comment

by:leakim971
ID: 41897454
So did you put the code on your site and it work fine but no feedback from you...

by the way you don't need this code anymore... that's why I put my line 1 in my previosu answer.
/* Footer Calendar */
var int = setInterval(function() {
    if ($('#footer-calendar').find('.picker__day').length > 0) {
        clearInterval(int);
        init_calendar();
    }
}, 100);

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now