[Seaside] I would like to attach an onClick event according to

Robert Sirois watchlala at hotmail.com
Fri Feb 4 01:55:14 UTC 2011


Try something along these lines (I didn't test it):
((html jQuery: #external_links) has: 'a')
would be confused if you executed it, because ids are unique ;)
Instead, generate your elements with a class, then try:
((html jQuery: '.external_links') has: 'a')
This will return all elements with the class "external_links" and then select from those, the ones that contain at least one anchor element.
Also, you would want to generate the original elements with the click events already on them, unless you were to do something complicated, like check to see if the element being clicked meets your criteria.
Alerts are not handled in Seaside, they are client side, so just evaluate a string :)
Hope this helps,
RS
> To: seaside at lists.squeakfoundation.org
> From: intrader.intrader at gmail.com
> Date: Fri, 4 Feb 2011 01:28:49 +0000
> Subject: [Seaside] I would like to attach an onClick event according to
> 
> the following JavaScript:
> <code>
> $('#external_links a').click(function() {
>     return confirm('You are going to visit: ' + this.href);
> });
> </code>
> The only elements receiving the onClick code are those divs that have anchors.
> 
> I have generated code using Seaside as follows:
> 5 divs with id 'external_links' that contain anchors, and 5 additional divs also 
> with id 'external_links' that just display text.
> The generated 'source' is:
> <code>
> <div id="external_links">
>   <a href="/whatever?_s=5NvhIEVCuZvzZGEz&_k=7kFMmFlVjrpxySMO&6">1</a>
> </div>
> <div id="external_links">
>   <a href="/whatever?_s=5NvhIEVCuZvzZGEz&_k=7kFMmFlVjrpxySMO&7">2</a>
> </div>
> <div id="external_links">
>   <a href="/whatever?_s=5NvhIEVCuZvzZGEz&_k=7kFMmFlVjrpxySMO&8">3</a>
> </div>
> <div id="external_links">
>   <a href="/whatever?_s=5NvhIEVCuZvzZGEz&_k=7kFMmFlVjrpxySMO&9">4</a>
> </div>
> <div id="external_links">
>   <a href="/whatever?_s=5NvhIEVCuZvzZGEz&_k=7kFMmFlVjrpxySMO&10">5</a>
> </div>
> <div id="external_links">just some content</div>
> <div id="external_links">just some content</div>
> <div id="external_links">just some content</div>
> <div id="external_links">just some content</div>
> <div id="external_links">just some content</div>
> </code>
> I don't know how to use Seaside to generate the javascript given above. I have 
> tried adding a button with an onClick event containing 'html jQuery 
> 'external_links a') click: [] - but I don't know what to say for the click: 
> message.
> 
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110203/a56ef227/attachment.htm


More information about the seaside mailing list