onChange and onBeforeChange events inverted

Hello all,
I just wanted to point out that in ver. 3.5, when using a calendar in a form, the functionality of these two events is inverted:
The onChange event fires before you confirm the change and the onBeforeChange fires after.

Hope this can help someone…

Marco

As a consequence of my findings above, now I have the following problem:
After selecting the date on the calendar, the onBeforeChange event fires, the input box updates correctly, BUT unfortunately the calendar remains open.
Can you help me find a solution so that the calendar closes correctly?
Thanks a lot for your help.
Marco

Hi
About 1th post: wait for an answer, please.
About 2th post: try to use calendar.hide()

WOW!
Thanks a whole lot! The hide worked perfectly… Darya, you’re incredible!!
Waiting is no problem at all… you made me operative again! :laughing:

You guys do a great support job!

Thanks again!
Marco

Hello Marco

Please provide completed demo for both cases

Hi Andrei,
thanks for your interest.
Since my code is rather long (700+ lines) and very database dependent for loading and saving the data on the form, I will try to make a small demo over the next few days… I should be able to reproduce the problem easily.
Greetings
Marco

Hi Andrei,
sorrry I made you wait for such a long time… :blush:
Please find attached the demo you asked for…

Pls. let me know if this helps!

Thanks again!
Marco
Sample.rar (152 KB)

Hello!
I’m sorry to bother you again, but I have a new problem, always on the same subject:
If the calendar field is blank, and the user opens the calendar, the time is initialized to the time in which you loaded the page.
NO event is fired at all in this situation, so you can’t initialize it as you need.
Could you look into this as well? Or is it me that I’m doing something wrong?
Thank you very much for your support!
Marco

Hi

sorry,seems like I missed your post :frowning:
your question with attach from " 31 Jan 2013, 18:21 " is still actual?

Hi

regarding sample.rar (at a quick glance, will check more detailed later)

  1. common.js should be first in a list (before calendar.js and form.js)

  2. y1.attachEvent(“onBeforeChange”,function(date){
    this is cancelable event, to calncel it you need to “return false” and to accept “return true”, struct w/o return at all means “undefined” which is equal to “return false” (so just add “return true;”)
    this is for first two “onBeforeChange”

  3. last “onChange” - you are correct, seems like seconds did the trick
    calendar have inner logic which is read data from input and updates date. seconds are not specified, so it take current value, which is different that was set while init.
    you can use myForm.attachEvent(“onChange”,…) (attached to form instead of to calendar) while I thinking over best way to fix it

Please try attached updates
calendar’s onChange fires when you change month/year/date/time in selector, use form’s onchange instead (any way calendar’s selector is fixed)
upd.rar (42.7 KB)

Hi Andrei,
I’m sorry but I don’t follow your coments…maybe this is the only problem now…
Let me try to show you what I did:var y1=myForm.getCalendar("x"); y1.attachEvent("onBeforeChange",function(date){ var y1=myForm.getCalendar("x"); var sH=y1.getFormatedDate("%H:%i"); if (sH == "" ) { myForm.setItemValue("x",sD); }; }); y1.attachEvent("onChange",function(date,state){ .... });
When you open the calendar for the first time, the input is blank, the onBeforeEvent fires, I assign the value sD to the calendar, and the calendar opens with the correct initial values.
Up to here, no problem at all…
1st problem: As soon as I change the time, the onChange event fires and the input box gets updated right away. In my opinion, this is not totaly correct because the user has not yet confirm the selection because the calendar is still open and he could change it again… Of course, is no big deal… just my point of view…
The 2nd problem is far more important… the user selects a date, so at this point the calendar should close. Correct? Instead what happends is that the onBeforeChange event is called again and the calendar remains open…!
Could you pls. look into this again?
Thank you very much!
Marco

Hi

calendar is not a good way to use time in a form cell. I recommend you two selects separated by a new column with hours and with minutes

regarding your logic:

  1. set dateFormat for input “%H:%i”
  2. do not use calendar’s events, this all will done automaticaly by form
  3. just init cell and let form do other things

Hi Andrei,
I don’t know why you are tellng me that calendar is not a good way to use time in a form since you are the one who helped me to show only 15 munute intervals, remember?.. and it works very well too (viewtopic.php?f=7&t=27588&p=88596#p88596)

Anyhow, I’ve decided that I’ll stay with my current version for now; I’ll have to initialize all the calendars when loading the form but it’s acceptable…
BTW, do you know when dhtmlxSuite 4.0 will arrive?

Thanks again for your continuous support!
Marco