Yep. Same goes for defaults and templatePartials !

On 9 Feb 2015 09:31, "Joaquin Oltra Hernandez" <jhernandez@wikimedia.org> wrote:
Hi!

Reviewing some of the patches that are migrating the views to use the events map, I've noticed that we need to be careful with the inheritance chains of Views we've got, if we don't do it properly we can override events of parent views, and break implicit behavior of a view (yay inheritance chains on a dynamic language with prototypes!).

I've written about it here Mobile_web/Coding_conventions/JavaScript/Views#Implementing_events_map_on_a_View_in_an_inheritance_chain Please tell me if it is not clear, feel free to improve it.

TLDR:
When implementing events map in a View:
  • if it has a parent class, use: $.extend({}, Parent.prototype.events, { ...
  • check if there are children classes that use events map, and do
    $.extend({}, View.prototype.events, { ... on them too.


_______________________________________________
Mobile-l mailing list
Mobile-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mobile-l