Use of onClick to call JavaScript

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Use of onClick to call JavaScript

Thomas McCune
In HTML it is possible to create a button in a form and cause Javascript to execute
using onClick. For example, the following form causes the JavaScript alert function
to be executed when the button is clicked.
 
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction('Hello');" name="username" />
Time: <input type="text" name="time" /><br>
<input type=BUTTON onClick="alert('GoodBye');" value="GoodBye" />
</form>
 
In Seaside, I have tried to achieve the same without success with the
following button definition:
 
renderDoItButtonOn: html
 
 html button with: 'Doit';
  onClick: 'alert("GoodBye");'.
 
The page refreshes but the JavaScript does not appear to execute. Is there a way
to accomplish this? I have tested onKeyUp: and it does execute the string as
JavaScript just as I expected.
 
Thank you

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Use of onClick to call JavaScript

Bob Arning
Hmmm.... try it with something other than a button. I think the clicking behavior is being pre-empted by the button itself.

Cheers,
Bob

On 10/22/10 5:52 PM, Thomas McCune wrote:
In HTML it is possible to create a button in a form and cause Javascript to execute
using onClick. For example, the following form causes the JavaScript alert function
to be executed when the button is clicked.
 
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction('Hello');" name="username" />
Time: <input type="text" name="time" /><br>
<input type=BUTTON onClick="alert('GoodBye');" value="GoodBye" />
</form>
 
In Seaside, I have tried to achieve the same without success with the
following button definition:
 
renderDoItButtonOn: html
 
 html button with: 'Doit';
  onClick: 'alert("GoodBye");'.
 
The page refreshes but the JavaScript does not appear to execute. Is there a way
to accomplish this? I have tested onKeyUp: and it does execute the string as
JavaScript just as I expected.
 
Thank you
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Use of onClick to call JavaScript

Robert Sirois
If the button isn't in a form block, it won't execute the callback (thereby refreshing the page).

You can also call #bePush on it so it doesn't execute.

ie.

html button
    bePush;
    onClick: (html jQuery this html: WACounter new);
    value: 'i turn into a counter dealybob!'.

Hope that helps,
RS via G1


Date: Fri, 22 Oct 2010 17:59:49 -0400
From: [hidden email]
To: [hidden email]
Subject: Re: [Seaside] Use of onClick to call JavaScript

Hmmm.... try it with something other than a button. I think the clicking behavior is being pre-empted by the button itself.

Cheers,
Bob

On 10/22/10 5:52 PM, Thomas McCune wrote:
In HTML it is possible to create a button in a form and cause Javascript to execute
using onClick. For example, the following form causes the JavaScript alert function
to be executed when the button is clicked.
 
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction('Hello');" name="username" />
Time: <input type="text" name="time" /><br>
<input type=BUTTON onClick="alert('GoodBye');" value="GoodBye" />
</form>
 
In Seaside, I have tried to achieve the same without success with the
following button definition:
 
renderDoItButtonOn: html
 
 html button with: 'Doit';
  onClick: 'alert("GoodBye");'.
 
The page refreshes but the JavaScript does not appear to execute. Is there a way
to accomplish this? I have tested onKeyUp: and it does execute the string as
JavaScript just as I expected.
 
Thank you
_______________________________________________ seaside mailing list seaside@... http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Use of onClick to call JavaScript

John McKeon


On Fri, Oct 22, 2010 at 6:57 PM, Robert Sirois <[hidden email]> wrote:
If the button isn't in a form block, it won't execute the callback (thereby refreshing the page).

I just tested that and it will perform the javascript without being in a form. 
The problem with the original code is that the "with:" message must come last, as it causes the tag to be serialized out to the context.

John 

You can also call #bePush on it so it doesn't execute.

ie.

html button
    bePush;
    onClick: (html jQuery this html: WACounter new);
    value: 'i turn into a counter dealybob!'.

Hope that helps,
RS via G1


Date: Fri, 22 Oct 2010 17:59:49 -0400
From: [hidden email]
To: [hidden email]
Subject: Re: [Seaside] Use of onClick to call JavaScript


Hmmm.... try it with something other than a button. I think the clicking behavior is being pre-empted by the button itself.

Cheers,
Bob

On 10/22/10 5:52 PM, Thomas McCune wrote:
In HTML it is possible to create a button in a form and cause Javascript to execute
using onClick. For example, the following form causes the JavaScript alert function
to be executed when the button is clicked.
 
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction('Hello');" name="username" />
Time: <input type="text" name="time" /><br>
<input type=BUTTON onClick="alert('GoodBye');" value="GoodBye" />
</form>
 
In Seaside, I have tried to achieve the same without success with the
following button definition:
 
renderDoItButtonOn: html
 
 html button with: 'Doit';
  onClick: 'alert("GoodBye");'.
 
The page refreshes but the JavaScript does not appear to execute. Is there a way
to accomplish this? I have tested onKeyUp: and it does execute the string as
JavaScript just as I expected.
 
Thank you
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
http://john-mckeon.us

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Use of onClick to call JavaScript

Robert Sirois
Ya #with: always goes last.

So.. did you figure it out?

RS via G1


Date: Fri, 22 Oct 2010 19:01:22 -0400
Subject: Re: [Seaside] Use of onClick to call JavaScript
From: [hidden email]
To: [hidden email]



On Fri, Oct 22, 2010 at 6:57 PM, Robert Sirois <watchlala@...> wrote:
If the button isn't in a form block, it won't execute the callback (thereby refreshing the page).

I just tested that and it will perform the javascript without being in a form. 
The problem with the original code is that the "with:" message must come last, as it causes the tag to be serialized out to the context.

John 

You can also call #bePush on it so it doesn't execute.

ie.

html button
    bePush;
    onClick: (html jQuery this html: WACounter new);
    value: 'i turn into a counter dealybob!'.

Hope that helps,
RS via G1


Date: Fri, 22 Oct 2010 17:59:49 -0400
From: arning@...
To: seaside@...
Subject: Re: [Seaside] Use of onClick to call JavaScript


Hmmm.... try it with something other than a button. I think the clicking behavior is being pre-empted by the button itself.

Cheers,
Bob

On 10/22/10 5:52 PM, Thomas McCune wrote:
In HTML it is possible to create a button in a form and cause Javascript to execute
using onClick. For example, the following form causes the JavaScript alert function
to be executed when the button is clicked.
 
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction('Hello');" name="username" />
Time: <input type="text" name="time" /><br>
<input type=BUTTON onClick="alert('GoodBye');" value="GoodBye" />
</form>
 
In Seaside, I have tried to achieve the same without success with the
following button definition:
 
renderDoItButtonOn: html
 
 html button with: 'Doit';
  onClick: 'alert("GoodBye");'.
 
The page refreshes but the JavaScript does not appear to execute. Is there a way
to accomplish this? I have tested onKeyUp: and it does execute the string as
JavaScript just as I expected.
 
Thank you
_______________________________________________ seaside mailing list seaside@... http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________ seaside mailing list seaside@... http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
seaside@...
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
http://john-mckeon.us

_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Use of onClick to call JavaScript

Johan Brichau-2
In reply to this post by Thomas McCune
Thomas,

#with: should always be the last message in a cascade. If you swap the position of #onClick: and #with:, it will work

This is something to remember, but you can get some help from the Lint code critics rules that come with 'Slime' (see seaside book). There is a rule that will detect mistakes like this.

Johan

On 22 Oct 2010, at 23:52, Thomas McCune wrote:

> In HTML it is possible to create a button in a form and cause Javascript to execute
> using onClick. For example, the following form causes the JavaScript alert function
> to be executed when the button is clicked.
>  
> <form name="myForm">
> Name: <input type="text"
> onkeyup="ajaxFunction('Hello');" name="username" />
> Time: <input type="text" name="time" /><br>
> <input type=BUTTON onClick="alert('GoodBye');" value="GoodBye" />
> </form>
>  
> In Seaside, I have tried to achieve the same without success with the
> following button definition:
>  
> renderDoItButtonOn: html
>  
>  html button with: 'Doit';
>   onClick: 'alert("GoodBye");'.
>  
> The page refreshes but the JavaScript does not appear to execute. Is there a way
> to accomplish this? I have tested onKeyUp: and it does execute the string as
> JavaScript just as I expected.
>  
> Thank you
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside