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

[AdminBundle] Dynamic reinit modules when a pagepart is added #849

Merged
merged 1 commit into from
Dec 14, 2015
Merged

[AdminBundle] Dynamic reinit modules when a pagepart is added #849

merged 1 commit into from
Dec 14, 2015

Conversation

dbeerten
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets /

Each time a new pagepart was added to a page, several javascript modules got reinitialised, even when they had nothing to do with this pagepart.

This feature makes it possible to just reinitialise one or more specific modules. This way, it is also possible to reinitialise modules which aren't default in the bundles.

screen shot 2015-11-30 at 11 04 40
This is an example of how you can trigger a reinitialise. Give the element a 'js-reinit' class and in the data attribute 'data-reinit-js' you can set the modules that need to be reinitialised for this pagepart.
It is important that the module has a public reInit function, because this is the function that will get triggered when the pagepart is added to the page.

if (modules) {
for (var i = 0; i < modules.length; i++) {
// Check if there really is a module with the given name and it if has a public reInit function
if (typeof kunstmaanbundles[modules[i]] !== 'undefined' && typeof kunstmaanbundles[modules[i]].reInit !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would explicitly check for 'function' here.

@Sambego
Copy link

Sambego commented Nov 30, 2015

Goed voor mij.

Misschien nog een improvement voor in de toekomst, nu maak je op sommige plaatsen een identieke init en reInit functie aan. Misschien moet je kijken of er een reInit functie is en als deze er niet is, gewoon de init functie uitvoeren?

Lijkt dit nog iemand een goed idee, of hoeft dat niet?

@diskwriter
Copy link
Contributor

@Sambego Zou dat precies willen vermijden vanwege risico dat je plugins gaat re-initializen die daar niet op voorzien zijn.

@Sambego
Copy link

Sambego commented Nov 30, 2015

ok

@jockri jockri added this to the 3.5.0 milestone Dec 14, 2015
jockri pushed a commit that referenced this pull request Dec 14, 2015
[AdminBundle] Dynamic reinit modules when a pagepart is added
@jockri jockri merged commit 9352126 into Kunstmaan:master Dec 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants