On Sep 10, 2006, at 9:48 AM, Matt Feifarek wrote:
> Hello.
>
> I'm using h.link_to() to stick some prototype/scriptalicious
> effects on the display/undisplay of dom elements. So far, so good.
> Very nice feature.
>
> It seems that most of the work in events and chaining events
> requires doing a round-trip with the server (AJAX) but I just want
> to do several client side events. I see the "before" and "after"
> and "complete" etc... but one can't use these to chain up client
> side scripts that don't have a server component, right?
>
> I think that MochiKit has some javascript implementation of
> twisted's Deferred object, and the chaining thereof, right? Can one
> use that with webhelpers?
>
> Specifically, I want to change the "display" style characteristic
> of a dom element (using an effect is nice). This element contains a
> form input. After I show it, I want to set the focus into the form
> element, but since link_to() uses the onclick to pass
> scriptalicious items to the function, I can't stick any "real"
> javascript code in there. I don't think that there is an ondisplay
> () event, and of course, the bit is already loaded, so onload()
> doesn't work.
>
> I looked through the source, and see how link_to parses the
> parameters to build attributes, and I thought that maybe I could
> send a tuple or a list in for onclick, but that just results in a
> string literal of what I sent to the function ending up html
> encoded in the output.
>
> So, in summary it seems that there is no way to use link_to() to do
> stuff like this:
> <a href="#" onclick="alert('foo1'); alert('foo2');">Hi</a>
>
You should be able to do:
h.link_to('click me', '#', onclick=h.visual_effect('highlight,
'posts', duration=0.5) + "alert('hi!')")
Beware not all of the javascript generation functions suffix their
code with semicolons (but visual_effect does -- I might consider that
inconsistency is a bug).
--
Philip Jenvey
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---