Closed derekr closed 12 years ago
What do you think of making the ajax call synchronous and having the full client call return data instead of passing in callbacks?
var data = client.app('myapp').model('mymodel').get({ id: 1 });
I think async + callbacks are necessary. I wrote a similar client but I have yet to extract it from my app if you wanna check it out: https://gist.github.com/32f57fb763a486949838
Can you guys duke it out and get back to me? I'm no JavaScript ninja. Derek, I work with Graham on a project that was the catalyst for creating django-ajax. He's been working with real-world django-ajax implementations so it'd be good to collaborate. Thanks for the contributions guys!
Right on. I feel @grahampage's implementation is more appropriate. It's simpler and feels like a jQuery plugin since you can access it in the same way ($.dajax.get(...)
). Any thoughts @grahampage?
I can verify that mine is working, so that is a plus! My library does not have the chaining but I think I like it better that way. If you want you could always add the chaining stuff to my library so we can support both.
I don't see chaining as being necessary. Personally I rarely chain ajax calls.
I'm going to close this for now. I'll figure it out with Graham.
Added a basic js client designed in the fashion I assumed you were going in. Static object with support for chaining operations.
I also moved it in to a
/static
subdirectory so that it works with Django'sstaticfiles
app out of the box.