[TYPO3-dev] Time for AJAX coordination?

Dmitry Dulepov typo3 at fm-world.ru
Sun Feb 12 09:49:41 CET 2006


Hi!

Michael Scharkow wrote:
> I meant something different: If I have a method render_page_tree() that
> returns some output (like the page tree in the BE) I want to use the
> very same method to produce a) the initial HTML output (as part of, say,
> the page module) *and* b) update the page tree with an AJAX call.
> 
> Since with xajax you always need to return an $objResponse->getXML(),
> you cannot easily use the same method for conventional output, that's at
> least my impression.

Not really. Xajax will call you ajax functions only and only if it was
an ajax request. If you use common function, you can either write it so
that it is independent from html/ajax or give it a flag that indicates
operation mode.

In my app I have a function that generates piece of information (complex
logic). It is called both from HTML and ajax version. It does not know
when it is called and even does not need to know because it is
independent. It just provides HTML representation of the data. Outer
functions will take this HTML, one will insert it to HTML page, another
send it using xajax. Outer functions are simple, inner is long and complex.

>> Well, we are talking about ajax library, not about generic JS library.
>> We are not going to bring scripaculos to typo3 just because it is fun,
>> are we? :)
> 
> Why not? What is an AJAX library in our definition: An interface to
> a) create JS AJAX calls in PHP code and
> b) return XML data back to the AJAX caller in PHP code.
> 
> The boilerplate code for the pure XMLHTTPRequest javascript can be found
> in a dozen libraries, including xajax, prototype.js, younameit.js.
> 
> What remains is a) getting the return output right and b) making it easy
> to connect links with AJAX calls in the most elegant manner. Or do drag
> and drop, dynamic input completion, etc.
> 
> While xajax doesn't help you with this (you have to write stuff like
> 
> <a href="#" onclick="xajax_doStuff('my_element'));">Do stuff</a>
> 
> yourself, using for example behaviour.js would make the AJAX call even
> less obstrusive because you can get rid of all the onclick=... in your
> HTML. Instead, we'd only include one or two external JS libraries and a
> little function registration code in dynamic JS (see
> http://bennolan.com/behaviour/)

Well, I prefer more control over the code...

> Why not include a generic, well-maintained JS library that can do AJAX
> *and* other niceties which we might need sooner or later, for example
> for our BE tab-dividers, type selectors, drag-drop etc.

Again, my preference is different. I prefer to have separate components
for separate task. Reason for this is simple: if you have all in one,
you ususally cannot replace one part of it. If you have generic library
that includes ajax, effects, blah-blah and bum-bum (do not know what
else) and you want another ajax library, you may encounter compatibility
problems between libraries and you still will have to include code that
you do not use.

Btw, xajax includes some methods similar to prototype (for example, $).
It makes my code browser independent, it is small and fast. So I am
happy with it. If I need scriptaculos or anything else, I can include it
separately.

We have a very useful and interesting discussion. Causes me to think
more about libraries...

Dmitry.
-- 
"It is our choices, that show what we truly are,
far more than our abilities." (A.P.W.B.D.)




More information about the TYPO3-dev mailing list