?
avatar avjoomla
avjoomla
21 Apr 2017

The function calendar() in JHtmlBehavior class is public static and can therefore be used directly in Joomla! component development. The function adds javascript and css files to the document.

In Joomla! 3.7. the function body of this function is empty (with exception of the code that adds a log entry, that the function is deprecated).
As a result any code, which uses the public static function calender() of the JHtmlBehavior class does not work as expected anymore and throws the Javascript error mentioned above.

The problem could be fixed by adding the original code from Joomla! 3.6.5 back into the function. Further on, the protected static function calendartranslation() which is used by calendar(), and was removed in Joomla! 3.7, is also needed.

Regards,
Aicha

avatar avjoomla avjoomla - open - 21 Apr 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Apr 2017
avatar dgt41
dgt41 - comment - 21 Apr 2017

@avjoomla can you share the code that you are using?

avatar franz-wohlkoenig franz-wohlkoenig - change - 21 Apr 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-04-21 09:02:11
Closed_By franz-wohlkoenig
Rel_Number 0 15441
Relation Type Related to
avatar joomla-cms-bot joomla-cms-bot - change - 21 Apr 2017
Closed_By franz-wohlkoenig joomla-cms-bot
Rel_Number 15441 0
Relation Type Related to
avatar joomla-cms-bot joomla-cms-bot - close - 21 Apr 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 21 Apr 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 21 Apr 2017

closed as having PR.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15440.

avatar avjoomla
avjoomla - comment - 21 Apr 2017

Thanks!

avatar infograf768
infograf768 - comment - 21 Apr 2017

@avjoomla
Please test and post test results in https://issues.joomla.org/tracker/joomla-cms/15441

avatar chavab1
chavab1 - comment - 22 May 2018

When updating from 3.6 to 3.7 I've run into a problem that I think it's related to this issue. I wasn't sure if I should start a new thread since it's related, so please forgive me.

I have a custom backend component where I give the users the option to add multiple date fields. These date fields are generated dynamically with javascript. On each of these fields I initialize a datepicker. It was working great until the 3.7 update. I kept on getting the Calendar is not defined error. Coming on this thread helped me figure out that problem as that error is no longer appearing. However, when I click on the button to open up the calendar I get the following error: Calendar is not a constructor. I've looked at the documentation but I can't find anything that indicates any changes to the calendar.js setup function. On this form I also have another jform datefield and that one does work. So I compared previous version to this 3.7 version and I can see on the old one the source code where the datepicker is being initialized and it's the exact same way as I'm doing it. However, after the 3.7 update I can't find anywhere on the source code where Joomla is initializing the datepicker for the jform field. I was hoping I could find it to use it as an example.

Another thing that I don't understand is why the jform datefield was working even before I added the fix document on this thread, but yet my fields were not.

Here is my code that I'm using:

      $("input[name^='jform[date]']").each(function(index){
        Calendar.setup({
          inputField: $(this).attr('id'),
          ifFormat: '%m/%d/%Y',
          button: $(this).attr('id') + '_img',
          align: 'Tl',
          singleClick: true,
          firstDay: 0
        });
      });

Thank you

avatar ggppdk
ggppdk - comment - 22 May 2018

Instead of Calendar.setup() you will need to use now JoomlaCalendar.init()

The new code should be something like

  • please make any corrections needed yourself and / or ask in Joomla forums as i will not answer here any more, i am posting this for anyone else also reading this issue
$("input[name^='jform[date]']").each(function(index){

	var theInput = $(this).attr('id');
	var container_id = 'box_' + theInput.attr('id');

	//theInput.closest('.someclassname').attr('id', container_id);
	//theInput.closest('.field-calendar').attr('id', container_id);
	theInput.parent().parent().attr('id', container_id);

	JoomlaCalendar.init(document.getElementById(container_id));

});
avatar chavab1
chavab1 - comment - 22 May 2018

@ggppdk
Thank you!! Really appreciate it.

Add a Comment

Login with GitHub to post a comment