javascript - Marionette. Add methods to view via behaviors -


so have:

  1. class mysuperbehavior extends marionette.behavior
  2. bunch of classes extends marionette.itemview , uses mysuperbehavior, tralalaview, trololoview etc

i want create method mysuperbehavior every instance of tralalaview , trololoview can use. how can correctly?

sample code illustrate:

 var mysuperbehavior =  marionette.behavior.extend({         awesomenonstaticmethod: function(){             console.log(this);         }     }); 

we suppose correct linking of classes

var tralalaview = marionette.itemview.extend({     behaviors: {       somebehavior: {         behaviorclass: mysuperbehavior       }     }   // methods here });  var instoftralala = new tralalaview(); console.log(instoftralala.awesomenonstaticmethod()); // want 

i did that:

 var mysuperbehavior =  marionette.behavior.extend({         initialize: function(options, view){             this.view.awesomenonstaticmethod = this.awesomenonstaticmethod         }         awesomenonstaticmethod: function(){             console.log(this);         }     }); 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -