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


Groups > comp.lang.javascript > #18633 > unrolled thread

Convert anonymous function to namned function

Started by"Tony" <tony.johansson@inport.com>
First post2013-02-26 10:07 +0100
Last post2013-02-26 12:08 +0100
Articles 5 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  Convert anonymous function to namned function "Tony" <tony.johansson@inport.com> - 2013-02-26 10:07 +0100
    Re: Convert anonymous function to namned function Gregor Kofler <usenet@gregorkofler.com> - 2013-02-26 10:29 +0100
      Re: Convert anonymous function to namned function "Tony" <tony.johansson@inport.com> - 2013-02-26 10:38 +0100
      Re: Convert anonymous function to namned function "Tony" <tony.johansson@inport.com> - 2013-02-26 10:42 +0100
      Re: Convert anonymous function to namned function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-26 12:08 +0100

#18633 — Convert anonymous function to namned function

From"Tony" <tony.johansson@inport.com>
Date2013-02-26 10:07 +0100
SubjectConvert anonymous function to namned function
Message-ID<kghtu0$kdo$1@dont-email.me>
Here I have an anonymous function which is working
$('#meetings').dblclick(function (e)
       {
          //Code to be moved to a named function
          alert("testing");
       });

and here I have tried to use a named function called Foo in this way but 
it's not working
$('#meetings').dblclick(Foo(e));
function Foo(e)
   {
         alert("testing in Foo");
   }

//What have I missed here ?

//Tony


[toc] | [next] | [standalone]


#18634

FromGregor Kofler <usenet@gregorkofler.com>
Date2013-02-26 10:29 +0100
Message-ID<kghv7t$qkc$1@dont-email.me>
In reply to#18633
Am 2013-02-26 10:07, schrieb Tony:
> Here I have an anonymous function which is working
> $('#meetings').dblclick(function (e)
>        {
>           //Code to be moved to a named function
>           alert("testing");
>        });
>
> and here I have tried to use a named function called Foo in this way but
> it's not working

Let me guess: You get an alert "when running", then "never again"? Hopeless.

> $('#meetings').dblclick(Foo(e));
> function Foo(e)
>    {
>          alert("testing in Foo");
>    }

$('#meetings').dblclick(Foo);


Gregor

[toc] | [prev] | [next] | [standalone]


#18635

From"Tony" <tony.johansson@inport.com>
Date2013-02-26 10:38 +0100
Message-ID<kghvp8$tc6$1@dont-email.me>
In reply to#18634
yes it's called only once but why ?
I mean I have created an event handler Foo for wiring up the double click on 
the meetings so
why is not Foo called when double click in the meetings ?

//Tony

"Gregor Kofler"  wrote in message news:kghv7t$qkc$1@dont-email.me...

Am 2013-02-26 10:07, schrieb Tony:
> Here I have an anonymous function which is working
> $('#meetings').dblclick(function (e)
>        {
>           //Code to be moved to a named function
>           alert("testing");
>        });
>
> and here I have tried to use a named function called Foo in this way but
> it's not working

Let me guess: You get an alert "when running", then "never again"? Hopeless.

> $('#meetings').dblclick(Foo(e));
> function Foo(e)
>    {
>          alert("testing in Foo");
>    }

$('#meetings').dblclick(Foo);


Gregor 

[toc] | [prev] | [next] | [standalone]


#18636

From"Tony" <tony.johansson@inport.com>
Date2013-02-26 10:42 +0100
Message-ID<kgi00e$ueg$1@dont-email.me>
In reply to#18634
I'm new to javascript and jQuery as you can see.
How do I get the event e from my Foo ?

//Tony




"Gregor Kofler"  wrote in message news:kghv7t$qkc$1@dont-email.me...

Am 2013-02-26 10:07, schrieb Tony:
> Here I have an anonymous function which is working
> $('#meetings').dblclick(function (e)
>        {
>           //Code to be moved to a named function
>           alert("testing");
>        });
>
> and here I have tried to use a named function called Foo in this way but
> it's not working

Let me guess: You get an alert "when running", then "never again"? Hopeless.

> $('#meetings').dblclick(Foo(e));
> function Foo(e)
>    {
>          alert("testing in Foo");
>    }

$('#meetings').dblclick(Foo);


Gregor 

[toc] | [prev] | [next] | [standalone]


#18638

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-02-26 12:08 +0100
Message-ID<2194862.j0WM3GWH8U@PointedEars.de>
In reply to#18634
Gregor Kofler wrote:

> Am 2013-02-26 10:07, schrieb Tony:
>> Here I have an anonymous function which is working
>> $('#meetings').dblclick(function (e)
>>        {
>>           //Code to be moved to a named function
>>           alert("testing");
>>        });
>>
>> and here I have tried to use a named function called Foo in this way but
>> it's not working
> 
> Let me guess: You get an alert "when running", then "never again"?
> Hopeless.

Do you realize that he is continuing to post that way as long as someone is 
(spoon-)feeding him?

<http://www.catb.org/~esr/faqs/smart-questions.html>

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web