html5 - How to handle particular event by the dynamic created button in sencha touch -


i have created 6 buttons dynamically using initialize function,also have assigned different id's each buttons dynamically,i want handle event each button,when click each of different button getting alert message of sixth button id,how handle particular button event. thank you

ext.define("dynamicbutton.view.main", { extend: 'ext.panel', initialize: function () { var me = this; me.names = ['button1', 'button2', 'button3', 'button4', 'button5', 'button6']; var toolbar = ext.create('ext.toolbar', { docked: "bottom" }); this.add(toolbar);  (var = 0; < me.names.length; i++) { var name = me.names[i]; var button = ext.create('ext.button', { id: 'btn' + name, html: name, handler: function() { alert(button.id); }, scope: }); toolbar.add(button); } }, config: { } }); 

you can access button through params of handler function :

handler: function (button, event) {      console.log(button.id); } 

i might useful if want change scope.

hope helps


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -