You must Sign In to post a response.
  • Category: JQuery

    clicking the Calendar arrows next/previous buttons and load the data once stop click

    I have a calendar image with previous and next button icon. If I click on the calendar image, calendar popup will open. After selecting the date then loading relevant gridload function. If I click the previous/next icon button, the gridload function execute without open calendar popup. I used the following code for that,

    var dateText = $(thisElement).parent().find('input.datepicker').datepicker('getDate');
    if ($(thisElement).hasClass('left-arrow')) {
    dateText.setDate(dateText.getDate() - 1);
    }
    else if ($(thisElement).hasClass('right-arrow')) {
    dateText.setDate(dateText.getDate() + 1);
    }
    $(thisElement).parent().find('input.datepicker').datepicker('setDate', dateText);
    $('.ui-datepicker-current-day').trigger('click');
    event.stopImmediatePropagation();

    My new requirement is, If I click previous/next button click it fast, trying to go back 2 or 3 days, the system won't try to load the grid data for each of those dates, and will just load it once they stop clicking.

    Please help for solving this issue.
  • #761137
    Hai Shajahan,
    Actually in your code:
    $('.ui-datepicker-current-day').trigger('click');
    is getting called each time when you go back and forth, becasue it will always get the value of the date picker using the below code snippet:
    $(thisElement).parent().find('input.datepicker').datepicker('setDate', dateText);
    So to fix the issue when you are clicking back and forth, you need to disable this event and it should only work when you are changing the value of the date picker. To do so, you can use .disableSelection()
    For more details, you can go to the below link:

    http://stackoverflow.com/questions/2155485/jquery-datepicker-cant-trigger-onselect-event-manually

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • Sign In to post your comments