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.
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?)?
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.
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?!
DOJO SOLUTION (in view script) ===================================
... load dojo libraries ...
<button onclick="javascript:
var kw = {
form: dojo.byId("listForm"), // form with var1/value1
url: "myController/myAction/format/ajax",
handleAs:"text",
load: function(response){
dojo.byId('myBox').innerHTML = response;
},
error: function(data){
alert("Holy Bomb Box, Batman! An error occurred: " +
data);
},
timeout: 2000
};
dojo.xhrGet(kw); // or: dojo.xhrPost(kw);
" >Replace the content in myBox</button>
<div id="myBox">Old content...</div>
PROTOTYPE SOLUTION (in view script) ==================================
... load prototype libraries ...
<button onclick="javascript:
new Ajax.Updater(success: 'myBox'},
'/myController/myAction/format/ajax/var1/value1');" >Replace the content in
myBox</button>
<div id="myBox">Old content...</div>
--
View this message in context:
http://www.nabble.com/Zend_Dojo-vs-Prototype-tp20757810p20803325.html
Sent from the Zend Framework mailing list archive at Nabble.com.