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:
- cls cannot bound there no setcls method - can bind iconcls if want
- you cannot add index after string such
iconcls:'{rating}'[0]
- syntactically incorrect - 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
Post a Comment