hyperlink - How to handle dom events in controller in extjs4? -
i working in extjs4, , getting stuck on how catch event on hyperlink. worked on couldn't solved.
here code:
view code
ext.define('am.view.user.linkview', { extend: 'ext.panel.panel', alias: 'widget.link', title: 'my cool panel', html: '<div><a href="#" id="linkid">this link open window</a></div><br /> <label for="myinput">type here: </label><input name="myinput" type="text" value="" />', });
controller code
ext.define('am.controller.users', { extend: 'ext.app.controller', stores: ['users'], models: ['user','book'], views: ['user.edit', 'user.list','user.create','user.linkview'], init: function() { this.control({ 'link': { afterrender: function(cmp) { ext.get('#linkid').on('click', function(event, target) { console.log(target); }, this); } } }); } });
when run code above error:
uncaught typeerror: cannot call method 'on' of null
how can solve problem?
change listener this:
afterrender: function(cmp) { cmp.mon(cmp.getel(), 'click', function(event, target) { console.log(target); }, this, {delegate: '#linkid'}); }
Comments
Post a Comment