el 有 ref 还是 jquery reference ?下面的代码片段
Is el having a ref or jquery reference ? code snippet below
this.$el = el instanceof Backbone.$ ? el : Backbone.$(el);
this.el = this.$el[0];
Backbone.$ 在下面的代码片段中是什么意思?是 Jquery 对 backbone 的引用吗?
更新:el instanceof Backbone.$
意思是检查 el
是否是 jQuery/zepto 对象。 Backbone.$
是 backbone 变量,用作 jQuery/zepto.
的别名
来自文档 http://backbonejs.org/#View-dollar
If jQuery is included on the page, each view has a $
function that
runs queries scoped within the view's element. If you use this scoped
jQuery function, you don't have to use model ids as part of your query
to pull out specific elements in a list, and can rely much more on
HTML class attributes. It's equivalent to running:
view.$el.find(selector)
this.$el = el instanceof Backbone.$ ? el : Backbone.$(el);
this.el = this.$el[0];
Backbone.$ 在下面的代码片段中是什么意思?是 Jquery 对 backbone 的引用吗?
更新:el instanceof Backbone.$
意思是检查 el
是否是 jQuery/zepto 对象。 Backbone.$
是 backbone 变量,用作 jQuery/zepto.
来自文档 http://backbonejs.org/#View-dollar
If jQuery is included on the page, each view has a
$
function that runs queries scoped within the view's element. If you use this scoped jQuery function, you don't have to use model ids as part of your query to pull out specific elements in a list, and can rely much more on HTML class attributes. It's equivalent to running:view.$el.find(selector)