Welcome Guest, Not a member yet? Register   Sign In
Ajax recommendation
#1

[eluser]garycocs[/eluser]
Hi Lads,

Just getting some more information from ye, I want to develop a few autocompletes and form submission ajax items on a new version of this site: http://www.ratemypub.ie I was just wondering which version should I use or would ye recommend, there seems to be scriptaculous and moo tools.

Since I'm using jquery already for a few rounded corners (bringing slides and that in shortly!) should I use scriptaculous? Or does that have anything really to do with jquery?

Not really sure what to go for at the moment so any help would be appreciated.

Thanks
Gary
#2

[eluser]whitey5759[/eluser]
In short yes you can use jQuery to implement the AJAX functionality you desire. I personally use YUI, but jQuery is just as good (it seems to be mostly personal preference when it comes to choosing between the two).

When it comes to the 5 most common AJAX frameworks, choosing between them is pretty much a random choice unless you see something about a certain framework that, in your mind, makes it more desirable over others. For us, it was either jQuery or YUI so we just stopped worrying about it and made a choice and have stuck with it.

That's just me 20 cents worth Smile
#3

[eluser]garycocs[/eluser]
I guess I would be nervous enough using something that there wouldnt be too many examples of, would you know of any helpful guides on integrating ajax calls with jquery and CI? I'm reading about files sizes and if I'm already loading in jquery for the rounded corners and other features I might stay with that if it saves me loading more files in.
#4

[eluser]bretticus[/eluser]
You can't go wrong with jquery. The core version supports basic effects: http://docs.jquery.com/Effects. What I really like about jquery is that you can easily separate your jquery logic from your html (you can obviously do this with basic javscript, but jquery makes it so easy.) This comes in real handy when you change layouts or change controls from checkboxes to radio buttons, etc (possibly bad example for lack of time.) It's very clean clean and it's good SEO practice to boot (hijax.) Don't get me wrong, I love scriptaculous. Especially for building some amazing GUI effects. I just prefer jquery for the reasons mentioned above. It's a good match for templates and views in my opinion.
#5

[eluser]garycocs[/eluser]
That kind of makes my mind up for me I guess.

How do you structure your jquery within CI? At the moment my rounded corners (going off the point) is in the view and I also call up the jquery.js and jquery.rounded.js within that view. Should I create my own .js file with my js functions within it?

Sorry if this doesnt make any sense, I'm terrible at trying to explain things!
#6

[eluser]whitey5759[/eluser]
The way I like to do it is yes, create my own JS file for each View so that there is NO Javascript at all in the actual View PHP, just a 'script' tag to include it. Directory wise I structure it like this:

/thewebsite/assets/css
/thewebsite/assets/images
/thewebsite/assets/js/views/theView.js
/thewebsite/system/application/views/theView.php

Nice clean seperation, and it also means that the JS will get cached by the browser and minimise your users downloads each time they refresh or re-visit a page.

Then your JS just calls functions in the corresponding Controller, and I get these functions to where appropriate return JSON so that in both PHP and JS you are dealing with objects (assuming that, like me, you return objects from your Model and not associative arrays), and not having to deal with objects in PHP, then arrays in JS, etc.
#7

[eluser]garycocs[/eluser]
Cool, that's good to know, I'm thinking all this file structure will be a massive benefit to me in development!

So going to go qith jquery, now I just have to figure out how to use it Big Grin

Links to a few good tutorials would be a great help!

Thanks lads!
#8

[eluser]jdfwarrior[/eluser]
I personally use jQuery to handle most AJAX stuff since I usually already have it loaded for something else anyway.
#9

[eluser]garycocs[/eluser]
Ya having a read up about it now, any good sites you could recommend for some tutorials?
#10

[eluser]jdfwarrior[/eluser]
[quote author="garycocs" date="1239728699"]Ya having a read up about it now, any good sites you could recommend for some tutorials?[/quote]

For using jQuery's AJAX functionality? Just check out jQuery's documentation on the $.post and $.get commands. Also is a pretty nice plugin I found a while back called Ajaxify(for jQuery) that will give you a nice loader and stuff as well if you are loading content into sections of the page. The developer for that plugin was pretty responsive when it came to asking questions and such too. I haven't used it lately though. I mostly just use the $.post command to post data from a page to a CI function, store it in the database or do whatever is needed, and pass a return value back, thats picked up in the callback and is handled appropriately.




Theme © iAndrew 2016 - Forum software by © MyBB