views:

67

answers:

3

Currently i am implementing the front-end of a djangoproject we have here. and we use Dajax (more precisely the Dajaxice) framework.

i don't know the framework, other than simply calling the server (which other developers here have setup with services that i can call to fetch all data)

it seems though that the dajaxice framework, does not fire the jquery ajax events (which if you think logically seems just) but i would like it to.

especially the global ajaxComplete event would be usefull in our case. so does anyone knowing dajax know how to modify dajaxice to call some or all of the jquery ajax events?

if this is not possible, does anyone know the equivalent? i need to use some code when ajax calls are complete, so if not with the jquery event binder, i would need another way to trigger if an ajax call was complete.

thanks in advance Sander

A: 

Hmm... I just took a (very) quick look at dajaxice and I did not get super warm fuzzies about it being "easy to use." I'll admit to a strong personal bias against systems that make me do a lot of plumbing (e.g. putting in specific 'onclick' events) and that was my reaction to dajax. In particular I hate having to create callbacks unless I really need to.

So my answer is to use the jQuery taconite plugin. It allows you to create a fire-and-forget ajax environment. I've used it on several projects and it makes 99% of AJAX-type situations embarrassingly simple to create.

Since I'm a Django developer I created a class to support the creation of properly formed taconite responses. A sample of the code is on my website. The example in the code is deliberately a little more involved than "Hello, World!" because I wanted to show that you can do multiple things (including firing off arbitrary Javascript) with a single taconite response.

Peter Rowell
Ok, thanks for taking the time to voice your opinion about both dajax and taconite, however i am not going to follow you into the whole taconite thing. I'm a big fan of keeping your controller away from the view. my dajax service should never have to know which elements are in my view and where to put the data. so taconite with the whole <append select="#id"></append> is totally wrong in my eyes, sorry that i'm so strongly against it but i'm going to keep looking for something else then.
Sander
Actually, I agree with you about the separation issue. My experience is that that rule of "Don't mix business logic, presentation logic, and content" is an ideal to be striven for, but AJAX throws a bit of a monkey wrench into the mix. The dajax code in the browser has to know enough to fetch the required information, and that often carries some knowledge about the business/presentation logic in it. As they say, TANSTAAFL.
Peter Rowell
A: 

Hi Sander, if your are using dajax you can use your own callback function and no 'Dajax.process'. For example in this Dajax normal usage:

Dajaxice.foo.my_ajax_function('Dajax.process');

You can write your own callback, for example:

function my_dajax_callback(data){
    Dajax.process(data);
    //Other stuff
}

And use it:

Dajaxice.foo.my_ajax_function('my_dajax_callback');

Hope This Helps You

Benito Jorge Bastida
thank you but yes i did know that,i was more looking for a general event, when you have 20 ajax calls, you'd want to process some logic on every callback, thus i would like to see something like the ajaxcomplete event in jquery, where you have a callback and a general ajaxcomplete.
Sander
A: 

As there is currently no support for ajaxcomplete or other ajax events like jquery has them, I chose to simulate the effect by manually calling a function called myAjaxComplete() from within every callback function.

its not the most clean way, i know that, but we need to wait for new versions of dajax and hope for event support.

Sander