Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25921

Re: eventDispath how that work

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.mb-net.net!open-news-network.org!aioe.org!.POSTED!not-for-mail
From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: eventDispath how that work
Date Thu, 16 Oct 2014 19:44:41 -0300
Organization Aioe.org NNTP Server
Lines 58
Message-ID <m1phoo$9o1$1@speranza.aioe.org> (permalink)
References <m1jblb$4a7$1@shakotay.alphanet.ch> <16yzpmtikrwk0$.1schjt968gcx$.dlg@40tude.net> <1791221.7QuZn8ShVB@PointedEars.de> <m1mk3b$9mh$1@shakotay.alphanet.ch> <2144937.rP2AIkvika@PointedEars.de> <m1odi8$2vg$1@shakotay.alphanet.ch> <m1ovsl$r9j$1@speranza.aioe.org>
NNTP-Posting-Host OotqgrO3DjHHh+mNTD09Xw.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.javascript:25921

Show key headers only | View raw


On 16/10/2014 14:39, Joao Rodrigues wrote:
> On 16/10/2014 09:26, Une Bévue wrote:

Complementing my last post.

>>
>> in the console log I got:
>> window.onload
>> sendTest(e)
>> documentReceiveBuildTest(e) event.type = build
>> bodyReceiveBuildTest(e) event.type = build
>>
>>
>> Then, the "<p id='para'>Listening to 'build' event...</p>" still doesn't
>> received this "build_event", and i still don't know why and where is my
>> error.
>> This time, this is the body :
>> document.body.dispatchEvent(build_event);
>> firing the event, then the "<p id='para'>Listening to 'build'
>> event...</p>" is clearly a child of it.
>>
> 
> 

I modified the OP's code to:

function documentReceiveBuildTest(e) {
  console.log("documentReceiveBuildTest(e) event.type = "
              + e.type);
}
function bodyReceiveBuildTest(e) {
  console.log("bodyReceiveBuildTest(e) e.detail.message = "
              + e.detail.message);
}
function paraReceiveBuildTest(e) {
  console.log("paraReceiveBuildTest(e) e.detail.time = "
              + e.detail.time);
}
function sendTest(e) {
  console.log("sendTest(e)");
  document.getElementById('para').dispatchEvent(build_event);
}
window.onload = function (e) {
  console.log("window.onload");
  document.getElementById('para').addEventListener('build',
    paraReceiveBuildTest, true);
  document.body.addEventListener('build', bodyReceiveBuildTest, true);
  document.addEventListener('build', documentReceiveBuildTest, true);
  document.getElementById('test').addEventListener('click',
    sendTest, false);
};

Tested with FF and Chrome last versions. IE11 apparently doesn't support
CustomEvent ... maybe using the old document.createEvent() and
event.initEvent() will do the job (not tested though).

-- 
Joao Rodrigues

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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