theironcook / Backbone.ModelBinder

Simple, flexible and powerful Model-View binding for Backbone.
1.42k stars 159 forks source link

Pass context to converter #223

Closed amakhrov closed 8 years ago

amakhrov commented 9 years ago

If a particular View needs some specific formatting for Model data, it can be done with converter parameter of a binding. However, this converter is not bound to the view, which makes it harder to define the converted as a View method (a workaround is to call _.bind or _.bindAll on it).

This PR offers an alternative and (hopefully) more elegant solution for that - specifying the context as a modelBinder option.

platinumazure commented 9 years ago

Just out of curiosity, could we also support a context declared in the binding itself? Presumably that would have priority over a global option, which in turn continues to have priority over the default function calling context.

amakhrov commented 8 years ago

Actually with es2015 arrow functions it no longer seems to be a valuable feature :)