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

Required attachments #2

Open
yckart opened this issue Mar 7, 2016 · 3 comments
Open

Required attachments #2

yckart opened this issue Mar 7, 2016 · 3 comments

Comments

@yckart
Copy link

yckart commented Mar 7, 2016

It would nice to have the possibility to add dependent attachments.

Sure, we could do this simply like so:

Attach.add('pluginName1', function(el) {
  var deps = el.dataset.split(' ')
  if (~deps.indexOf('pluginName2') && ~deps.indexOf('pluginName4')) {
    // stuff
  }
})

...however, makes sense to me to let this managed internally:

Attach.add('pluginName1', ['pluginName2', 'pluginName4'], function(el) {
  // stuff...
})

Update
Just don't know what's the best way to go. Either check if the current node resolves all dependencies, or for the existence of those dependencies somewhere in the dom...

@mrmartineau
Copy link

@yckart I agree. I have been using Attach on a project recently and have often found issues with loading and instantiation where one attachment depends on another, or if one manipulates the DOM onLoad/DOMContentReady and another is skipped because it sits within it.. (don't think that makes sense, butI think this sort of interface might help.

@nicbell
Copy link
Owner

nicbell commented Mar 7, 2016

@mrmartineau in situations where you have several modules that depend on each other I would write another module that governs their creation and any other inter-dependent logic. I would attach this module to the parent container instead of attaching all the child modules.

For example if you had several types of filters on a page that triggered each other. You could keep those filters single purpose and create a FilterManager module to take care of the depended business logic between the filters.

@yckart
Copy link
Author

yckart commented Mar 7, 2016

Let's assume that we want to add an editor to some sort of input field and in some cases (wysiwyg instead of markdown mode, or whatever reason) also a toolbar. This toolbar requires that the editor is attached, as the editor give's access to the current value and selection.

This might be not the best example, but would be a case where it could be helpful to have this feature available.

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

No branches or pull requests

3 participants