jQWidgets Forums

jQuery UI Widgets Forums Editors Calendar jqxCalendar change event with range

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 11 years, 11 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • adonati
    Participant

    Hello,

    I am using a Calendar widget set to mode:’range’. I am binding to the ‘change’ event to intercept when the range changes. Everything works well except for one thing: I cannot select a single day as the date range. If I click on a day, then click on the same day, the ‘change’ event is not fired.

    I saw that the jqxDateTimeInput control works correctly (it accepts one-day ranges), but I can’t get the same for the Calendar widget.

    I am using the latest jqWidgets library. My code for the calendar and event is below:

    $('#jqxCalendar').jqxCalendar({   theme: theme,   width: 215,   selectionMode: 'range'});
    $('#jqxCalendar').on('change', function (event) {
       if (event.args.range.from != event.args.range.to) {
          var filterValue = event.type + ': ' + event.args.range.from + " - " + event.args.range.to;
          alert(filterValue);
       }
    });

    Thank you


    Dimitar
    Participant

    Hello adonati,

    The event is called properly. However, in this case event.args.range.from is equal to event.args.range.to and that is why your alert is not called. Please, check out the demo Range Selection for an example.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    adonati
    Participant

    Dimitar,

    This is not what I see, the change event does not fire when selecting the To date, if it’s the same as the From date. I opened your Range selection example page in IE, loaded it in the F12 tools, and set a breakpoint in the Change event. The event is not fired on the second click to the same date. Once I select a new date (event is fired the first time), I can keep clicking that same date over and over and over, with no more events. I can see that the calendar UI reacts correctly ( it disables prior dates between first and second click), but no event is raised.

    Another point about the dates being the same in my code and thus skipping the alert(): the Calendar widget adds 23:59:59 to the To date when selecting the range, so that filtering from date X to date Y is inclusive of day Y. This would cause even my code to show an alert if the event was fired, because I compare date & time.

    Please try this again and let me know. If you see the event firing, maybe you can post an example where the text below the calendar shows both date AND time: this way, I will be able to see that the time of the To date changes from 0:00:00 to 23:59:59 when selecting the To date.

    Thank you,


    Dimitar
    Participant

    Hi adonati,

    The change event is fired only on the first click. As shown in the demo, the first click sets the clicked date as the start and end date.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    adonati
    Participant

    Dimitar,

    Is this a bug? In every other case, the event is fired twice – when clicking on the first date (.from) and when clicking on the second date (.to). If the event is only fired once when the date is the same, how am I supposed to know that the user is done selecting a range?

    As I wrote before, the first click does not behave the same way as the second: on the second click, the widget is supposed to add 23:59:59 to the .To date.

    jqxCalendar change event with range #22848

    Dimitar
    Participant

    Hi adonati,

    Thank you for the feedback. This is not a bug, but we will consider improving the change event behaviour in future versions of jQWidgets.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.