小编Gam*_*mak的帖子

全局命名空间会被污染是什么意思?

全局命名空间会被污染是什么意思?

我真的不明白受污染的全局命名空间意味着什么.

javascript

87
推荐指数
3
解决办法
3万
查看次数

Backbone.js视图中的EL和模板

所以我对backbone.js很新,而且一般不太擅长JavaScript,所以我想知道是否有人可以向我解释为什么

我无法在我的视图中定义我的EL属性和Template属性,然后在我的渲染中使用this.template.相反,我必须在我的渲染功能中定义模板和el.

    var ProductView = Backbone.View.extend({
    el: $('#product-list'),

    initialize: function() { 
            this.el.html('<span style="color:white">loading...</span>'); 
    }, // end initialize


    render: function(collection) { 
    //    // assign the template 
          this.template = $('#product_template');

          // Where the template will be placed  
          this.el = $('#product-list'); 

          // Add the collection to the main object 
          this.collection = collection;

          // add tthe data to the html variable 
          var html = this.template.tmpl(this.collection.toJSON());

          // place the html in the element. 
           this.el.html(html);

           // not even sure what the hell this is. 
          return this; …
Run Code Online (Sandbox Code Playgroud)

javascript views backbone.js

3
推荐指数
2
解决办法
9373
查看次数

标签 统计

javascript ×2

backbone.js ×1

views ×1