Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the calendar to work in the subform field #13153

Merged
merged 1 commit into from
Jan 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions media/system/js/fields/calendar-vanilla.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,16 @@
}
};

/** Init the Calendars on the page */
JoomlaCalendar.init = function (className) {
/**
* Init the Calendars on the page
*
* @param {String} className The field class name (required)
* @param {HTMLElement} container The field container (optional)
*/
JoomlaCalendar.init = function (className, container) {
var elements, i, instance;

elements = document.querySelectorAll(className);
elements = (container || document).querySelectorAll(className);

// Fall back for translation strings
window.JoomlaCalLocale = window.JoomlaCalLocale ? JoomlaCalLocale : {};
Expand Down Expand Up @@ -1065,6 +1070,10 @@
/** Instantiate all the calendar fields when the document is ready */
document.addEventListener("DOMContentLoaded", function() {
JoomlaCalendar.init(".field-calendar");

window.jQuery && jQuery(document).on("subform-row-add", function (event, row) {
JoomlaCalendar.init(".field-calendar", row);
});
});

})(window, document);