backbone.epoxy icon indicating copy to clipboard operation
backbone.epoxy copied to clipboard

Access to view in bindingHandlers

Open rubenstolk opened this issue 12 years ago • 3 comments

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.

rubenstolk avatar Nov 06 '13 07:11 rubenstolk

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

gmac avatar Dec 14 '13 19:12 gmac

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...

rubenstolk avatar Dec 15 '13 08:12 rubenstolk

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) {
        // ...
    }
}

kottenator avatar Jul 15 '14 14:07 kottenator