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

Access to view in bindingHandlers #48

Open
rubenstolk opened this issue Nov 6, 2013 · 3 comments
Open

Access to view in bindingHandlers #48

rubenstolk opened this issue Nov 6, 2013 · 3 comments

Comments

@rubenstolk
Copy link
Contributor

I think it would be nice if the bindingHandlers are called with a 3rd argument which is the view, this will make it easier to access for example given options on the view.

@gmac
Copy link
Owner

gmac commented Dec 14, 2013

Could you provide an implementation example to demonstrate what you're referring to, please?

@rubenstolk
Copy link
Contributor Author

Currently bindingHandlers are kind of static functions without any context. If for example I want to calculate something based on information available in the view, this is currently not possible. That's why I think it would be a great option to be able to have access to the view...

@kottenator
Copy link

I have found one workaround:

this inside a custom binding handler in a reference to the model and inside the model there is a view link:

bindingHandlers: {
    myHandler: function($element, value) {
        var view = this.view;
        // ...
    }
}

However, this is not a good solution, because the model could be used in different views at the same time...

It would be good if Epoxy developers would add an additional argument to the handler function:

bindingHandlers: {
    /** @param {Backbone.View} view */
    myHandler: function($element, value, view) {
        // ...
    }
}

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