backbone-views

Backbone.View “el” confusion

两盒软妹~` 提交于 2019-11-27 05:57:37
How should a view's el be handled? It has to be set, otherwise events don't fire (see here ). But should it be an element that is already on the page? In my app, I render a (jQuery Templates) template into a Fancybox. What should the el be in that case? LeRoy A views el is where all the event binding takes place. You don't have to use it but if you want backbone to fire events you need to do your rendering work on the el. A views el is a DOM element but it does not have to be a pre-existing element. It will be created if you do not pull one from your current page, but you will have to insert

Backbone.View “el” confusion

坚强是说给别人听的谎言 提交于 2019-11-27 03:58:34
问题 How should a view's el be handled? It has to be set, otherwise events don't fire (see here). But should it be an element that is already on the page? In my app, I render a (jQuery Templates) template into a Fancybox. What should the el be in that case? 回答1: A views el is where all the event binding takes place. You don't have to use it but if you want backbone to fire events you need to do your rendering work on the el. A views el is a DOM element but it does not have to be a pre-existing

Backbone.js - change not triggering while the name change

 ̄綄美尐妖づ 提交于 2019-11-26 14:56:47
问题 In my backbone function, while the name get change the change function not at all triggering.. any one suggest me the right way to get it.. (actually i need to get changed stuff and need to update); code : (function($){ var list = {}; list.model = Backbone.Model.extend({ defaults:{ name:'need the name' }, initialize:function(){ this.bind('change:name', function(model) { console.log('Model->change()', model); }); } }); list.collect = Backbone.Collection.extend({ model:list.model, url : 'data

Listen to changes from nested model attributes

可紊 提交于 2019-11-26 14:52:43
问题 I have a model attribute which is an object: name : "testing", orderCondition: { minOrderAmount: 20, deliveryCostRequire: "MIN_ORDER_AMOUNT", deliveryCostAmount: 5.55 } When I use listenTo like this, the render function is not called this.listenTo(this.model, "change:orderCondition", this.render); // NO FIRING But when I use listenTo on other attributes, it works. this.listenTo(this.model, "change:name", this.render); // FIRING Why listenTo doesn't see changes in nested objects but see them