Typescript Marionette UI object -


i have tried implementing marionette itemview in typescript , wanted use ui object simplify calls ui elements described in marionette documentation.

i made following example simplify it:

/// <reference path="scripts/typings/marionette/marionette.d.ts" />  interface settings {     el:     template: function }  class myapp extends marionette.itemview<backbone.model> {     constructor(options: settings) {         super(options);     }      ui = {         hello: '.hello'     }      events() {         return {             'click @ui.hello': 'heyworld'         }     }      heyworld() {         console.log("hey heyworld!!!!");     } }  window.onload = () => {     var app = new myapp({         el: document.getelementbyid('content'),         template: (data) => {             return '<div class="hello"><p>hej world - click me</p></div>';         }     });     app.render(); }; 

which returns "uncaught typeerror: cannot read property 'hello' of undefined"

if change ui object following starts work seems bit hacky way of getting work:

get ui() {         return {             hello: '.hello'         }     }      set ui(value) {          // somehow marionette want set this.ui empty object      } 

has run issue before? got way of implementing marionette ui object avoids awkward get/set ui code?

the solution quite simple. had pass ui object options object like:

class myapp extends marionette.itemview<backbone.model> {     constructor(options: backbone.viewoptions<backbone.model>) {         this.ui = {             hello: '.hello'         }         super(options);     }      events() {         return {             'click @ui.hello': 'heyworld'         }     }      heyworld() {         console.log("hey heyworld!!!!");     } } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -