And now with the correct url... sorry for the spam
https://www.mediawiki.org/w/index.php?title=Mobile_web/Coding_conventions/J…
On Mon, Feb 9, 2015 at 6:31 PM, Joaquin Oltra Hernandez <
jhernandez(a)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.