[Catalyst] AJAXPrototype Questions

Yuval Kogman nothingmuch at woobling.org
Thu Sep 8 19:59:57 CEST 2005


On Thu, Sep 08, 2005 at 10:28:03 -0400, Christopher H. Laco wrote:
> I guess I'm looking for more detail as to what magic goes on behind the scenes 
> of the prototype stuff.

HTML::Prototype generates java script code which can be composed
easily.

This code is centered around HTML requests, the place to shove them
into, and the callbacks to call when events happen.

The most basic thing is to "update" a DOM element by fetching some
HTML, which is then set to the contents of the DOM element.

Most methods are centered around this:

	c.prototype.link_to_remote(
		"link text",
		{
			update => "dom_id",
			url => "the url to get",
		}
	);

This example creates a link <a href="...">link text</a>, which when
clicked fetches the URL, and puts the resulting content in the dom
element whose id is "dom_id".

for example if you have a photo gallery with thumbnails as links
(link text is "<img ... />"), and a <div> which is updated with the
full image.

form_remote_tag behaves almost exactly the same... It opens a <form>
which when submitted will also do this kind of stuff. I use it in a
login box, a <div> with this form_to_remote in it. The form replaces
itself, and shows either an error message with the same form, or a
logout button.

The callbacks are "before", "after", "complete", and so on and so
forth. I think they're documented on some wiki somewhere.

In the same form I have a "complete" handler which will look for a
dom element called "login_error", and apply the highlight effect to
it if it exists.

c.prototype.visual_effect just returns a bit of code that when
evaled will cause the effect to happen, so you can use it as a
javascript snippet safely.

This is pretty much it... Form observers behave like link_to_remote,
for example, i think that auto_complete is just some precooked
styling and not much more. The "server side" generates a bunch of
<li>s, and the client side just puts that in a div that magically
appears under the input form.

I haven't played with the draggable stuff, but it seems pretty
streight forward from here on.

I hope this helps!

-- 
 ()  Yuval Kogman <nothingmuch at woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: /me has realultimatepower.net: neeyah!!!!!!!!!!!!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20050908/a2bddad4/attachment-0001.pgp


More information about the Catalyst mailing list