javascript - Backbone.js View not rendering my json file -
After
I am new to backbone.js and want to keep a json file called, Products have been loaded into the archive, but it has not been render only. Send me the If someone can help me, thanks! In your ShopView list, an audience for the 'Reset' event , So when the scene is stored the view will be re-provided. To present the model, you will need to change the template to look like this: and ProductItemView : products.json .
render () function & amp; Underscore.js.
initialize: function () {_.bindAll (this, 'render'); This.collection = New Shoplist (); This.listenTo (this.collection, 'reset', this.render, this); This.collection.fetch ({reset: true}); // check url path this.render (); } Render: function () {var self = this; This.collection.each (function (item) {var view = new ProductItemView ({model: items}); $ (self.el) .append (view.render ());}); This return; }
render: function ($ {$ (this.el) .html ( This.template (this.model.toJSON ())); This return; }
Comments
Post a Comment