javascript - How can addCls to Button with ViewModel binding in ExtJS5 -


i want change css class after binding. possible in extjs5?

i added comments. fiddle: https://fiddle.sencha.com/#fiddle/olc

you have several problems in code:

  1. cls cannot bound there no setcls method - can bind iconcls if want
  2. you cannot add index after string such iconcls:'{rating}'[0] - syntactically incorrect
  3. if define rating formula have run function - get()

try code

ext.define('fiddle.view.foomodel', {     extend: 'ext.app.viewmodel',     alias: 'viewmodel.fiddle-foo',      data: {         val: 1     },      formulas: {         rating: function(get) {             get();             return 'hello-world';         }     } });  ext.define('fiddle.view.foo', {     extend: 'ext.panel.panel',     xtype: 'fiddle-foo',      viewmodel: {         type:'fiddle-foo'     },      layout: 'hbox',     height: 50,     width: 250,     items: [{         xtype: 'button',         text: 'rating 1',         bind:{          iconcls:'{rating}'         }     }, {         xtype: 'button',         text: 'rating 2',         bind:{          iconcls:'{rating}'         }     }, {         xtype: 'button',         text: 'rating 3',         bind:{          iconcls:'{rating}'         }     }]   });  ext.application({     name: 'fiddle',      launch: function() {         new fiddle.view.foo({             renderto: document.body,             width: 400,             height: 400,             title: 'test'         });     } }); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -