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

Unregister Selectors #13

Open
paynecodes opened this issue Feb 12, 2014 · 2 comments
Open

Unregister Selectors #13

paynecodes opened this issue Feb 12, 2014 · 2 comments

Comments

@paynecodes
Copy link

I'm going to use this in a production environment. Is there any chance you would either add, or accept a PR for unregistering selectors?

Use case: For a single page app, I'm thinking of writing a Grunt task that will create a JSON object with all of my possible selectors like this:

{
    ".elem1": {
        "min-width": [ "600px" ],
        "max-width": ["700px"]
    },
    ".elem2": {
        "min-height": ["20em"]
    },
    ".elem3": {
        "min-width": ["20em", "30em", "40em"]
    }
}

I'm not going to pass a laundry list of selectors to elementQuery, but instead, each of my Backbone Views will be responsible for:

  1. Registering new elementQuery selectors used by the view and calling refresh() by passing true.
    • Basically, I will be listing the query selectors used for this view like elQueries: ['.elem1', '.elem2']
    • Just after the view has been rendered into the DOM, I will match the selectors from elQueries to the Grunt generated JSON object to register only selectors needed for a given view.
  2. Unregistering elementQuery selectors that are no longer on the page (ie, when the view closes)

How does everyone feel about something like this?

@AntonTrollback
Copy link

+1
I hope you share that grunt task :)

@tysonmatanich
Copy link
Owner

@jpdesigndev sorry to not respond sooner, yes I am open to a PR to unregister a selector. If it adds much file size at all, you might want to write it as a plugin in a separate JS file since I imagine not many people will be unregistering selectors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants