[TYPO3-dev] Time for AJAX coordination?

Michael Scharkow mscharkow at gmx.net
Fri Feb 10 21:29:54 CET 2006


Dmitry Dulepov wrote:

> Current ajax code is not working properly. We need a better ajax
> implementation. Xajax is the best in my opinion because of its features
> (registration, easy replacement of elements, attrributes, etc).

Hi Dmitry,

I just had a look into XAJAX and I am really sceptical if it fits us. 
The assignment and registration functions don't look particularly 
elegant to me, and the replacements (and lots of other stuff) are 
defined in the called function and not in the caller.

Just imagine you have a function called comment_form() that you want to 
call with AJAX. With xajax you have to know in advance which div you 
want to fill with the form because you do

$objResponse->addAppend("myDiv1","innerHTML",$DataFromDatabase2);
return $objResponse;

If you want to call the same function but fill a *different* div, you're 
screwed. Moreover, you can't use the same controller method for both 
normal HTML and AJAX output which is also a must IMHO.

In Rails you write this in your view:
<%= link_to_remote( "comment this article",
                          :update => "mydiv1",
                          :url =>{ :action => :comment_form }) %>

So you can set the div in the caller and reuse the comment_form method 
everywhere in your app.

Moreover, XAJAX does *only* do AJAX stuff, whereas for example 
prototype.js has lots of other neat JS features like observers (for 
forms etc.) and powerful selector functions.

I'm not saying that prototype (and behaviour.js for complete 
unobstrusiveness) is definitely better, but we should carefully look at 
the relevant options before making a decision.

Of course, we would need to provide our own PHP wrappers, but we have 
t3lib_ajax already, and we could concentrate on making the wrapper 
functions perfect for TYPO3 and not worry about the JS and AJAX basics.

Greetings,
Michael




More information about the TYPO3-dev mailing list