?
avatar PhocaCz
PhocaCz
26 Apr 2017

Steps to reproduce the issue

Joomla! 3.7 RC 4 - create the calendar dynamically (e.g. with help of Javascript), initialize the calendar after pasting this calendar to html:
JoomlaCalendar.init(".field-calendar");
Works as expected - calendar of dynamically created item is initialized and it works.

Joomla! 3.7 Stable
Create the calendar dynamically (e.g. with help of Javascript), initialize the calendar after pasting this calendar to html:
JoomlaCalendar.init(".field-calendar");

Does not work:

calendar.min.js:45 Uncaught TypeError: Cannot create property '_joomlaCalendar' on string '.field-calendar'
    at new JoomlaCalendar (calendar.min.js:45)
    at Function.JoomlaCalendar.init (calendar.min.js:1102)
JoomlaCalendar @ calendar.min.js:45
JoomlaCalendar.init @ calendar.min.js:1102

Expected result

You can initialize calendar for newly dynamically created items on the site like in Joomla! 3.7 RC4

Actual result

Works in Joomla! 3.7 RC4, doesn't work in Joomla! 3.7 Stable

System information (as much as possible)

Joomla! 3.7 RC4 vs. Joomla! 3.7 Stable
PHP7

Additional comments

avatar PhocaCz PhocaCz - open - 26 Apr 2017
avatar joomla-cms-bot joomla-cms-bot - change - 26 Apr 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 26 Apr 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Apr 2017
Category JavaScript
avatar PhocaCz
PhocaCz - comment - 26 Apr 2017

Ok, seems like I found the problem.
media\system\js\fields\calendar.min.js

Init function parameter changed, from className to element

FROM
@param {String} className The field class name (required)
TO
@param {Node} element The element node

So instead of initializing with the class name:
JoomlaCalendar.init(".field-calendar");

in version RC4

it should be initialized with element:

elements = document.querySelectorAll(".field-calendar");
   for (i = 0; i < elements.length; i++) {
      JoomlaCalendar.init(elements[i]);
   }

in Stable

I hope, there will be no more changes regarding the function parameter. If no, this issue can be closed but developers should get informed about the change (I hope this topic can help when somebody runs into the same problem).

Jan

avatar PhocaCz
PhocaCz - comment - 26 Apr 2017

Can be closed as it is not an issue but change between RC4 and Stable

avatar PhocaCz PhocaCz - change - 26 Apr 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-04-26 12:22:20
Closed_By PhocaCz
avatar PhocaCz PhocaCz - close - 26 Apr 2017
avatar ggppdk
ggppdk - comment - 26 Apr 2017

@PhocaCz

..., this issue can be closed but developers should get informed about the change (I hope this topic can help when somebody runs into the same problem).

Thanks for bring this up , i have missed this change too,

yes i see that in J3.7 we need to use
JoomlaCalendar.init(element);

instead of in the J3.7 RCs
JoomlaCalendar.init(selector);

Add a Comment

Login with GitHub to post a comment