Page 1 of 1

Can't set the all day event field to true on form load

Posted: 23 Feb 2016
by mcgaafar
Hi,

I'm trying to set the all day event checkbox on a new calender form to checked (True) on form load via javascript as follows:

fd.field('fAllDayEvent').value('1');

however it's not working.

Appreciate your help, and thanks in advance.

Re: Can't set the all day event field to true on form load

Posted: 24 Feb 2016
by rostislav
Hi,

Try this:

Code: Select all

 fd.field('fAllDayEvent').control()._el().find('input').attr('checked', true);

Re: Can't set the all day event field to true on form load

Posted: 24 Feb 2016
by mcgaafar
Thanks for the reply, yes this made the all day event checkbox checked now, however the time controls for start time and end time of the event did not hide like the default behavior, so how can i get this to work?

Thanks again.

Re: Can't set the all day event field to true on form load

Posted: 25 Feb 2016
by rostislav
Try this:

Code: Select all

 fd.field('fAllDayEvent').control()._el().find('input').click();

Re: Can't set the all day event field to true on form load

Posted: 26 Feb 2016
by mcgaafar
Thanks a lot for your reply, it really helped, just to avoid an infinite loop of checking and unchecking the field, i had to place your code in IF condition, here's the code that worked for me:

var allday = fd.field('fAllDayEvent').control()._el().find('input').is( ":checked" );
if (allday == false){
fd.field('fAllDayEvent').control()._el().find('input').click();
}