Backbone.js - Given an element, how do I get the view?

后端 未结 5 1818
刺人心
刺人心 2020-12-15 03:33

I\'ve created a bunch of Backbone.js views. Each view has an associated element (view.el).

Given an element on the page — out of context of the view — w

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 03:57

    You could maintain a views hash (dictionary) that uses the element as the key and returns the view (or views).

    http://www.timdown.co.uk/jshashtable/

提交回复
热议问题