Page 1 of 1

showCalendar is not defined

Posted: Fri Sep 14, 2007 3:05 am
by uweD
Hi,

I try to use the Java Script  showCalender() function on the front end. This works fine on the back end

Code: Select all

<?php
JHTML::_('behavior.calendar');
?>
<input type="text" class="inputDate" id="dateFieldXYZ" /><input type="reset"  value="..." onclick="return showCalendar('dateFieldXYZ','d-mm-yy')" />
            


But: If I use the same lines on the front end I just get an error message that 'showCalender' is not defined.

Anyone an idea how to use that functionality on the front end?

Thanks,
Uwe

Re: showCalendar is not defined

Posted: Sat Sep 15, 2007 1:01 pm
by mtlnews
hey Uwe

im just learning php and joomla right now, and I came across the same problem. What I did was I added this code to the top of the view.html.php file where I want the calendar to show up:

// includes for mini-calendar
$lang =& JFactory::getLanguage();
JHTML::script( 'calendar_mini', 'includes/js/calendar/' );
JHTML::script( 'calendar-'. $lang->getTag(), 'includes/js/calendar/lang/' );

I wrote " 'calendar-'. $lang->getTag() " instead of just " calendar-en-GB " because eventually, I might add the french language..

Re: showCalendar is not defined

Posted: Sun Sep 16, 2007 6:06 am
by uweD
Hi mtlnews,

Thanks for that! I will try it at work tomorrow. Thanks a lot for your help,

Uwe

Re: showCalendar is not defined

Posted: Sun Sep 16, 2007 8:50 pm
by uweD
Hi mtlNews,

Your solution did not work for me as I ran into the same problem. But I compared the JS includes in the admin area and the front page where I tried to use the calender. One libraries is missing on the front end - don't ask me why...

Anyway: I added the following lines and everything seems to work fine now:

Code: Select all

   $document = &JFactory::getDocument();
   $document->addScript("includes/js/joomla.javascript.js");


Thanks for your replies,

Uwe