-
2 Aug 2012 12:51 PM #1
Firing Custom Events from UI components
Firing Custom Events from UI components
Can anyone give a final and complete description if it is possible in Sencha Architect 2 to make a button fire a custom event "myevent" and controller listening for and correctly getting it.
So far I could not find a place where in the Button config to put addEvents("myevent") so it will be correctly bubbled up.
the line 13850: in the ext-all-debug.js is where the fireEvent("myevent") dies.
continueFireEvent: function(eventName, args, bubbles) {
var target = this,
queue, event,
ret = true;
do {
if (target.eventsSuspended === true) {
if ((queue = target.eventQueue)) {
queue.push([eventName, args, bubbles]);
}
return ret;
} else {
13850: event = target.events[eventName];
if (event && event != true) {
if ((ret = event.fire.apply(event, args)) === false) {
break;
}
}
}
} while (bubbles && (target = target.getBubbleParent()));
return ret;
},
-
2 Aug 2012 1:15 PM #2
Find attached a simple project which fires a custom event.
Hope this helps.
Regards.
event.xda
Edit:
Updated project which fires custom event from custom button's click.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
2 Aug 2012 1:29 PM #3UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
2 Aug 2012 2:54 PM #4
I would like to thank you very much.
This is one definitive and straightforward example that answers so many questions at once.
Basically one needs to "Promote To Class" UI object (say button) and then he will be able to drag and drop "Custom Event" from toolbox or from config window add it through + on newly appeared category Custom Events.
Without Promoting to Class custom events won't be able to work with in Sencha Architect.
Thank you. +100
-
2 Aug 2012 2:59 PM #5
UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
2 Aug 2012 3:34 PM #6
Thank you.
Would it possible to use bubbleEvents array on "promoted" button class to send custom event to the top window and attach controller to only the window, without doint the chain
var win = button.up("window");
win.fireEvent("myevent", win);
-
2 Aug 2012 5:21 PM #7
UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
3 Aug 2012 11:48 AM #8
fireEvent
fireEvent
Hello,
Have you tried listening for the button event on the view and then using fireEvent to fire and event that the controller can listen to?
I don't know your case, but in MVC I'm not sure how often you need to do that.


Reply With Quote