-
20 Nov 2012 7:56 AM #1
Answered: MVC Panel Click event
Answered: MVC Panel Click event
Is it possible to attach the click event handler for a panel body using Ext.app.Controller.control() . Tried by firing the event in the panel
but even then cant able to catch the handler function corresponding to it in the control() method.Code:listeners: { click : { fn: function(e, t) { this.fireEvent('click', t); }, element: 'el', scope: this } }
to the panel bodyCls and the cls added entity_draw.Code:this.control( { '[cls~=entity_draw]':{ click:this.drawPanel, scope:this } });
-
Best Answer Posted by vietits
Try this:
1. View code
2. ControllerCode:Ext.define('App.view.Panel', { extend: 'Ext.panel.Panel', alias: 'widget.apppanel', bodyCls: 'entity_draw', ... listeners: { click: { element: 'el', fn: function(){ var panel = Ext.getCmp(this.id); panel.fireEvent('click'); // fire 'click' event from panel } } } });
Code:... init: function(){ this.control({ 'apppanel': { // 'panel[bodyCls=entity_draw]' click: function(){ console.log('panel is clicked'); } } }); }
-
22 Nov 2012 6:18 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,118
- Vote Rating
- 453
- Answers
- 3160
The component doesn't have a click event but the element does.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
22 Nov 2012 6:36 AM #3
simoens but the class is provided in bodyCls only and when inspected the html the class was correctly present in the div even then below code is not working.
code by which panel is createdCode:'[class~=entity_draw]':{ click:this.drawBoardEntity, scope:this }
Code:var panel = Ext.create('Ext.panel.Panel', { width: 200, height: 100, floating: true, draggable: true, renderTo:Ext.get('sworkspace'), html: displayString, bodyCls:'entity_draw' });
-
30 Nov 2012 2:56 AM #4
what is the exact equivalent code for mvc style panel click listener.
-
30 Nov 2012 5:01 AM #5
Try this:
1. View code
2. ControllerCode:Ext.define('App.view.Panel', { extend: 'Ext.panel.Panel', alias: 'widget.apppanel', bodyCls: 'entity_draw', ... listeners: { click: { element: 'el', fn: function(){ var panel = Ext.getCmp(this.id); panel.fireEvent('click'); // fire 'click' event from panel } } } });
Code:... init: function(){ this.control({ 'apppanel': { // 'panel[bodyCls=entity_draw]' click: function(){ console.log('panel is clicked'); } } }); }


Reply With Quote