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


Groups > comp.lang.javascript > #25920

Re: eventDispath how that work

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: eventDispath how that work
Date 2014-10-16 14:39 -0300
Organization Aioe.org NNTP Server
Message-ID <m1ovsl$r9j$1@speranza.aioe.org> (permalink)
References (1 earlier) <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>

Show all headers | View raw


On 16/10/2014 09:26, Une Bévue wrote:
> Le 15/10/14 23:39, Thomas 'PointedEars' Lahn a écrit :
>>>     <head />
>> Invalid, see<http://validator.w3.org/>.
>>
> 
> obviously it was a "symbolic" way to shortened the code...

<head /> is invalid markup.

> 
>> as is From header field value of your
>> postings (which you want to fix before your next posting)
> 
> The From header is due to Thunderbird 24.6.0, what is wrong with that ?

Personally, I don't see any problem in a French header, but I think that
Thomas will say you should adjust your newsreader (Thunderbird) language
to English because comp.lang.javascript (c.l.js) is an international
newsgroup...

> 
> Anyway, I rewrote my code:
> <!doctype html>
> <html lang="en">
> <head>
>   <meta charset="UTF-8" />
>   <title>dispatch-event</title>
>   <script>

Just the <script> tag is ok according to W3C Proposed Recommendation for
HTML5:
<http://www.w3.org/TR/html5/scripting-1.html#attr-script-type>

However, some regulars in c.l.js will certainly complain that you should
specify the type attribute for the sake of compatibility with older
browsers.

>   var build_event;
>   window.onload = function(e) {
>     console.log("window.onload");
>     build_event = new CustomEvent("build", {
>       detail: {
>         message: 'toto',
>         time: new Date(),
>       },
>       bubbles: true,
>       cancelable: true
>     });
>     test.addEventListener('click', sendTest, false);
>     test = document.getElementById('test');

I think you meant:
var test = document.getElementById('test');
test.addEventListener('click', sendTest, false);

>     document.addEventListener('build', documentReceiveBuildTest, true);
>     document.body.addEventListener('build', bodyReceiveBuildTest, true);
>     document.getElementById('para').addEventListener('build',
> paraReceiveBuildTest, true);
>   }
>   function documentReceiveBuildTest(e) {
>     console.log("documentReceiveBuildTest(e) event.type = " + event.type);
>     return true;
>   }
>   function bodyReceiveBuildTest(e) {
>     console.log("bodyReceiveBuildTest(e) event.type = " + event.type);
>     return true;
>   }
>   function paraReceiveBuildTest(e) {
>     console.log("paraReceiveBuildTest(e) event.type = " + event.type);
>     return true;
>   }

In the three functions above, substitute + event.type for + e.type.

>   function sendTest(e) {
>     console.log("sendTest(e)");
>     document.body.dispatchEvent(build_event);
>   }
>   </script>
> </head>
> <body>
>   <p id='para'>Listening to 'build' event...</p>
>   <button id='test' data-date='16 oct 2014'>sendTest</button>
> </body>
> </html>
> 
> 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.
> 


-- 
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