-- Marc Grue <[EMAIL PROTECTED]> wrote
(on Tuesday, 02 December 2008, 03:19 PM -0800):
> Matthew Weier O'Phinney-3 wrote:
> > Look into dojo.xhr:
> >     
> >    
> > http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/ajax-transports
> > 
> > There's not a direct equivalent to Ajax.Updater, but it's trivial to use
> > dojo.place to inject the content into your DOM via a load callback.
> > 
> 
> Thanks for the link and guidance, Matthew!
> 
> I messed around with the dojo.xhr parts and found a solution that worked
> (sending a form) but wasn't as elegant as my old prototype way (sending
> var/value pairs). I have included both below if somebody can use them.

You can pass a "form" key to the XHR call, and point it to the form's
DOM node. If you're using Zend_Dojo_Form (and thus dijit.form.Form),
you'll need to do this:

    form: dijit.byId("<your form ID here>").domNode,

This will send all form elements as key/value pairs in the request.

> When debugging in firefow, I also noticed that the dojo library loaded a
> long list of files taking up some time whereas the prototype library was
> only one file. I certainly don't want to say that "dojo is better than
> prototype" - I have way to little knowledge about both libraries, but I
> wonder if the "overhead" could be avoided when loading the dojo libraries
> (using 1 file?)?

Dojo is highly modular, which makes it easy to debug, maintain, and
understand. The downfall, of course, is lots of micro requests. The
upside is that Dojo provides a build tool that allows you to compile all
these files into a single file, complete with comment stripping,
whitespace removal, and more. I've blogged about it as well as presented
on the topic... and will have an article in an upcoming issue of
php|architect covering it as well.

> I have some follow-up questions:
> How can I get the response back from the action in my controller and
> 'cancel' all other aggregated content in the view? Do I have to use
> contextSwitch action helper somehow, or am I on the wrong track?
> Embarrasing: for now I do an *ugly* die($content) to just abort and echo the
> data back.

Disable the layout and the view renderer. If you use ContextSwitch or
AjaxContext helpers, this is done automatically.

> I'm also sending a format variable with the ajax call to determine in my
> action if I should send back the result to an ajax call or if it's a
> 'normal' request where all subsequent actions should carry out and build the
> whole page. But shouldn't I be able to detect an ajax call without the
> format variable?!

Use the AjaxContext helper, which detects the "X-REQUESTED-WITH:
XMLHttpRequest" header.


-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to