Skip to content

Unregister Selectors #13

@jarrodpayne

Description

@jarrodpayne

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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions