Page 1 of 1

Calendarpopup in javascript

PostPosted: Tue Sep 30, 2008 11:28 am
by yalbinus
Maybe this is the wrong forum to post my problem but I give it a try.

In Dynamic AI 5.1 we use javascripts to fill datefields.
A user clicks the datefield. Then a popups shows a calendar. The user only has to click the right day. It is also possible to change the years and months. After clicking a day the popup disappears and the selected date shows up in the datefield.
All works fine.

The same javascript we want to use in Dynamic 6 but it doesn't work.
After clicking a datefield, the calendarpopup shows. But clicking any day, month/year doesn't work.
The browser returns an error:
Error: g_calendar' not defined
This error doesn't show using Dynamic 5.1.

Tried to define g_calendar but I can't solve this problem.
(Why does it work in version 5.1 and not in version 6?)
Does anyone have a clue?

PostPosted: Wed Oct 01, 2008 11:26 am
by Carsten Sørensen
Hi,

In principle there should be no reason why this shouldn't work in version 6.

I assume that you implement the date pop-up via a rules script - is there any way where you can share that with me in order for us to re-produce and fix the problem?

best regards,
Carsten

PostPosted: Thu Oct 02, 2008 3:29 pm
by yalbinus
I've sent a mail with the code.

PostPosted: Fri Oct 03, 2008 12:04 am
by Carsten Sørensen
Hi Yuori,

In v6 we use <a href notation to handle onclick events, mouseover etc. much more than we did in previous versions of Dynamic AI. We changed to the more solid <a href methodology in order to improve compatibility of Dynamic AI across browsers, PDA's, IPhones etc. I believe we have succeeded with that in v6.

The problem as I have been able to figure it out with the date pop-up script is that it is also using the <a href method and the pop-up script get's a challenge with the general BODY BASE target, BASE href etc.

If you load the report from the Dynamic AI menu (using the drop-down) and load into a new window/tab, where the BASE target by default in Dynamic AI is set to self etc. then your current scipt is working also in v6.

If you look at your onclick events then I was successfully able to use the pop-up within the normal Dynamic AI context if I modify the following way:

Code: Select all
  tmpStr += '<a class="cal" "javascript: g_Calendar.clickDay(' + iCount + ');">' + iCount + '</a>';

to

Code: Select all
  tmpStr += '<a class="cal" href=# target=self onclick="javascript: g_Calendar.clickDay(' + iCount + ');return false;">' + iCount + '</a>';


You'll have to modify also the month and year click events.

By the way - It's a nice add-on to Dynamic AI - well done!!!

best regards,
Carsten

PostPosted: Fri Oct 03, 2008 12:14 pm
by yalbinus
Hi Carsten,

Thanks for the quick fix.
It works just as it did in version 5.1.

By the way, I didn't write the add-on.
The script works perfect. Maybe a bit slow when changing months and years but less chance to insert wrong dateformats.

Thank you very much.

Best regards,
Youri