Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jQuery Canlendar click function

Posted on 2016-11-19
5
Medium Priority
?
88 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses how to implement server side field validation and display customized error messages to the client.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
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…
Suggested Courses

705 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