[Catalyst] sane AJAX strategy
Daniel McBrearty
danielmcbrearty at gmail.com
Fri Jan 5 11:24:37 GMT 2007
I just started using AJAX (or AHAH actually ... ) a little. I like the
lightness it gives but I've been slow to pick up because I want to be
sure that pages work without js, and I haven't figured out a generic
method yet. I'm sure others are ahead of me on this ...
Typical scenario without AJAX :
form button submits to URL, which triggers a single Cat action, which
is rendered by a single template, usually of the same name.
That's simple, just a one-to-one relationship.
When we use AJAX, things look very similar, EXCEPT that only a part of
a page is loaded.
This implies that for the non-js user of the same page, multiple
actions and templates have been combined so that the result is
identical, even though the whole page loaded.
An example:
(in the .js file)
// button foo gets an event sends query to /foo, puts result into bar
(html)
<div id="bar">Nothing selected.</div>
<form target="whole_page">
.
.
.
<input type="button" id="foo" value="Select something">
</form>
(controller)
# get a whole page
# here we need to check whether foo was a from submit or not
# if not render page with defaults
# otherwise render page using foo to fill in bar
sub whole_page :Local {
}
# select a bar
sub foo {
}
Now this will be happening a lot ... what's a nice way to organise
this without too much repetiton? Does some library code exist already?
cheers
Daniel
--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
More information about the Catalyst
mailing list