JQuery GET without link_to_remote. How?

Hi,
I start to use JQuery with Rails:
I should make a simple text link to call in Ajax (by GET) an action in
controller.

link_to_remote is a Prototype method, I would use just a javascript
framework (JQuery).

Is it possible to use “link_to” to make ajax call ?
(I didn’t have succeed )
What I should use instead of link_to_remote ?

Thank you !
Alessandro

On Tue, Oct 20, 2009 at 6:05 PM, Ale Ds
[email protected] wrote:

Hi,
I start to use JQuery with Rails:
I should make a simple text link to call in Ajax (by GET) an action in
controller.

link_to_remote is a Prototype method, I would use just a javascript
framework (JQuery).
OK, Prototype is a Javascript framework and happens to be the default
for Rails, but link_to_remote is a Rails method.
If you’re gonna use jQuery on your Rails application, you better
install the jrails plugin[1] which will give you the proper
replacements for those helper methods.

Is it possible to use “link_to” to make ajax call ?
Yes, it is.

(I didn’t have succeed )
What I should use instead of link_to_remote ?
You could use any click handler function and perform an $.ajax or
$.get or $.post call in that handler, jQuery docs has the right
information for you.

[1]http://wiki.github.com/aaronchi/jrails


Leonardo M…
There’s no place like ~

There are a number of great railscasts that cover this topic.

It is possible to use the jrails plugin. It is also possible to code
your application using unobtrusive javascript, which may be another
good topic to study. That way you remove a lot of the clutter from
your views.

sax

Leonardo M. wrote:

On Tue, Oct 20, 2009 at 6:05 PM, Ale Ds
[email protected] wrote:

Hi,
I start to use JQuery with Rails:
I should make a simple text link to call in Ajax (by GET) an action in
controller.

link_to_remote is a Prototype method, I would use just a javascript
framework (JQuery).
OK, Prototype is a Javascript framework and happens to be the default
for Rails, but link_to_remote is a Rails method.
If you’re gonna use jQuery on your Rails application, you better
install the jrails plugin[1] which will give you the proper
replacements for those helper methods.

Is it possible to use “link_to” to make ajax call ?
Yes, it is.
yes, you are right.
I have resolved in this way:
in the view
<%= link_to(‘Update table’, users_path(@user) ,:id => ‘id_update_link’)
%>
and in application.js
$(‘#id_update_link’).click(function(){
$.get($(this).attr(“href”), $(this).serialize(), null,
“script”);
return false;
});

thank you,
Alessandro