javascript - Why view doesn't listen model events -


i have basic model such as:

    define(['backbone', 'relational'], function(backbone, relational) {         var resultentitymodel = backbone.relationalmodel.extend({             defaults : {                 bgoccurence : "",                 fgoccurence : "",             },             initialize : function() {                                    var bgoccurence = this.set("bgoccurence",this.get("bgoccurence"));                        var fgoccurence = this.set("fgoccurence",this.get("fgoccurence"));             }         });          return resultentitymodel;     }); 

and view:

define(['marionette', 'js/models/result/result.entity.model', 'text!templates/result/result.entity.panel.html'], function(marionette, resultentitymodel, resultentitypanel) {     var resultentityview = marionette.compositeview.extend({         tagname : "tr",         template : resultentitypanel,         initialize: function () {             this.model.on("change:fgoccurence", function() { console.log("hello"); });       }                           });     return resultentityview; }); 

but code doesn't print hello console. couldn't find problem i'm pretty sure view doesn't listen change event why? help.

when u passing model view, initialized, attributes set, change events triggered. try create instance of model (didnt used requirejs syntax, pseudo code based on local variables):

var model = new resultentitymodel(); var view = new resultentityview({model: model}); model.set('bgoccurence', 'new value bg'); 

and u can see console log.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -