jQWidgets Forums
Forum Replies Created
-
Author
-
November 29, 2012 at 9:26 am in reply to: Current date selection on month navigation problem Current date selection on month navigation problem #11691
Hi Peter,
I’ve tried to avoid the loop by exit the event procedure when currentDate==selectedDate. The strange thing is for example when I’ve navigate backwards, when I’ve set selectedDate the event is triggered again with the currentDate in the previous month.
Putting the set of selectedDate in a timer this was not happen anymore.
For example, for backwards navigation the following code:
$(‘#calendar’).bind(‘valuechanged’, function (event) {
var mDate= event.args.date;
var seldate=$(“#calendar”).jqxCalendar(“selectedDate”);
if (seldate.getFullYear()!=mDate.getFullYear() || seldate.getMonth()!=mDate.getMonth() || seldate.getDate()!=mDate.getDate()){
$(“#calendar”).jqxCalendar(“selectedDate”,new Date(mDate.getFullYear(),mDate.getMonth(),mDate.getDate()));
return;
}//do some stuff here
}is going into infinite loop by decreasing one month at each loop.
And the following code:$(‘#calendar’).bind(‘valuechanged’, function (event) {
var mDate= event.args.date;
var seldate=$(“#calendar”).jqxCalendar(“selectedDate”);
if (seldate.getFullYear()!=mDate.getFullYear() || seldate.getMonth()!=mDate.getMonth() || seldate.getDate()!=mDate.getDate()){
setTimeout(‘$(“#calendar”).jqxCalendar(“selectedDate”,new Date(‘ + mDate.getFullYear() + ‘,’ + mDate.getMonth() + ‘,’ + mDate.getDate() + ‘));’,200);
return;
}//do some stuff here
}is working good.
I’m just wondering if this is a best approach or if you have a better solution to set the selected date equal with current date when the enduser navigate thru calendar.
Thank you,
CostinNovember 28, 2012 at 6:58 pm in reply to: Current date selection on month navigation problem Current date selection on month navigation problem #11638Thank you for tip. I didn’t know about selectedDate.
How can I set the selected date. I’ve tried to change with $(“#calendar”).jqxCalendar(‘selectedDate’,somedatevalue) on valuechanged, but is trigger a chain infinite loops of events decreasing/increasing month by month.
I’ve found a workaround by setting the selectedDate with a delay in timeout (200 ms), but I’m not sure that is the best solution.
Best regards,
CostinNovember 28, 2012 at 11:12 am in reply to: Current date selection on month navigation problem Current date selection on month navigation problem #11594Hi Peter,
Something is confusing me. What is affecting the methods setDate and getDate , the Current date or Selected date?
For me is important to have the same values in getDate return and the UI. It’s there a way to do this?
Thank you very much,
CostinNovember 28, 2012 at 10:33 am in reply to: Current date selection on month navigation problem Current date selection on month navigation problem #11589Hi Peter,
Thank you for the quick response.
I use the valuechanged event in order to do some stuffs and I use the event argument date:
$(‘#jqxCalendar’).bind(‘valuechanged’, function (event) {
var date = event.args.date;
doing something with the date}
When pressing the navigation buttons the view is changed indeed with the previous/next month and also the value from event argument is changing too. Even with getDate method I’ve get the new value from previous/next month. This is good for me, but the problem is that UI is not updated accordingly.
You can see this behavior in demos:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxcalendar/index.htm#demos/jqxcalendar/events.htmwhen you navigate, the event log is filled with the new dates which are in current month, but the UI is not updated.
Thanks,
Costin -
AuthorPosts