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
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 |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Rel_Number | 15441 | ⇒ | 0 |
Relation Type | Related to | ⇒ |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/15440
closed as having PR.
Thanks!
@avjoomla
Please test and post test results in https://issues.joomla.org/tracker/joomla-cms/15441
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
Instead of Calendar.setup()
you will need to use now JoomlaCalendar.init()
The new code should be something like
$("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));
});
@avjoomla can you share the code that you are using?