Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25905
| From | Une Bévue <unbewusst.sein@fai.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | eventDispath how that work |
| Date | 2014-10-14 16:23 +0200 |
| Organization | Posted through ALPHANET (http://www.alphanet.ch/) |
| Message-ID | <m1jblb$4a7$1@shakotay.alphanet.ch> (permalink) |
Iv' tried eventDispatch but doesn't understand how it works really.
Say, in my html i have a paragraphe :
<p id='elem'>Listening to 'build' event...</p>
it listen to the CustomEvent 'build' :
elem.addEventListener('build', function (e) {
console.log("'elem' listener: event.type = " + event.type);
console.log("'elem' listener: event.detail = " + event.detail);
},
false
);
next, i have a button 'test' :
<button id='test' data-date='14 oct 2014'>sendTest</button>
which listen to two events :
test.addEventListener('click', sendTest, false);
test.addEventListener('build', receiveBuildTest, true);
when the click event occurs the function sendTest create a new event and
dispatch it :
function sendTest(e) {
console.log("sendTest(e) e:");
console.dir(e);
event = new CustomEvent('build', { 'detail': e.target.dataset.date });
e.target.dispatchEvent(event);
}
well this new event is received by the 'test' element in the function
receiveBuildTest :
function receiveBuildTest(e) {
console.log("receiveBuildTest(e) e:");
console.dir(e);
}
BUT the paragraphe element 'elem' does not receive this event even if it
listen to by :
elem.addEventListener('build', function (e) {
console.log("'elem' listener: event.type = " + event.type);
console.log("'elem' listener: event.detail = " + event.detail);
},
false
);
Why ?
In fact i don't understand why this event could only be recived on the
element who has generated it, not interesting...
as far as i understand...
What i want to do :
send an event to other parts of the dom from one having receive one from
user click, by example.
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-14 16:23 +0200
Re: eventDispath how that work JJ <jj4public@vfemail.net> - 2014-10-15 03:24 +0700
Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-15 10:49 +0200
Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-15 15:24 +0200
Re: eventDispath how that work JJ <jj4public@vfemail.net> - 2014-10-16 02:10 +0700
Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-15 23:02 +0200
Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-15 18:59 -0300
Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-16 02:48 +0200
Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-16 18:11 +0200
Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-15 22:06 +0200
Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-15 23:39 +0200
Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-16 14:26 +0200
Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-16 14:39 -0300
Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-16 19:44 -0300
Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-17 09:00 +0200
Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-17 10:16 -0300
Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-17 21:40 +0200
Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-17 17:03 -0300
Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-18 15:46 +0200
Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-17 08:26 +0200
csiph-web