-
27 Aug 2010 5:22 PM #1
Unanswered: Is this even possible create element and listening and fire event?
Unanswered: Is this even possible create element and listening and fire event?
I am looking at creating something like this in ExtJS, it seems that jQuery has a very nice handy feature here.
http://www.bennadel.com/blog/1998-Us...-DOM-Nodes.htm
When I write the code like this, I get a weird error.
uncaught exception: Error listening for "ping". Element "undefined" doesn't exist.
The code is
Anyone have any ideas on how to achieve this?Code:freeNode = new Ext.Element('div'); freeNode.on('ping', function() {alert('You pinged me');});
-
27 Aug 2010 11:42 PM #2Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
But do you really NEED an element?
If you just want to fire events from SOMETHING, instantiate an Observable.
Code:var myComponent = new Ext.util.Observable(); myComponent.on('ping', function(){alert("ping");}) myComponent.fireEvent("ping");Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
28 Aug 2010 12:25 AM #3
Thanks Animal, I sort of figured I could do that. I was curious on more of whether one could create an element that was detached from the DOM and still be able to apply events to it.
Come to think of it I am not even sure of a good case that one would need too.
-
28 Aug 2010 12:37 AM #4Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
There is no use case.
That blog post is just ignoring the heffalump in the room, that jQuery has no Observable base class!Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
Similar Threads
-
Textfield event listening
By alupuli in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 24 Feb 2010, 4:32 PM -
Fire event on element
By TrickOfTheMind in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 28 Apr 2008, 7:23 AM -
Listening to an Element inside an iframe (MINI-GUIDE)
By Neo in forum Ext 1.x: Help & DiscussionReplies: 7Last Post: 23 Aug 2007, 2:05 AM


Reply With Quote