How to use link_to with :remote=>true in rails 3.2.1

I m using Rails 3.2.1. how to use link_to with remote=>true


My Method in Controller

def clickme
@clk = “you click me”
respond_to do |format|
format.js { render :layout=>false }
end
end

My View
In my new.html.erb file

<%= link_to “click here”, {:action=>“clickme”}, {:remote => true,
:id=>“clk”} %>

<%= render :partial => 'goclick' %>

_goclick.html.erb

<%= @clk %>


clickme.js.erb

$("#allclick").update("<%= escape_javascript(render(:partial =>
“goclick”)) %>");

On my web-page everything is fine when I click on click here link
nothing change. But when I check Firebug console it shows me:

$("#allclick").update(“you click me”);


In My application.js

//= require jquery
//= require jquery_ujs

Help Me :frowning:

You probably want to use $("#allclick").update instead of
$(“allclick”).update

Note the # that indicates you are selecting an element by the ID.

Tim S. wrote in post #1049440:

You probably want to use $("#allclick").update instead of
$(“allclick”).update

Note the # that indicates you are selecting an element by the ID.

I’m using $("#allclick").update

On Mar 1, 2012, at 2:09 AM, Manish N. wrote:

====================================================================
Instead of update now I’m using html

Update would work perfectly if you were using Prototype.js instead of
jQuery.

Walter

after doing some googling I got the answer

wrong way :
$("#allclick").update("<%= escape_javascript(render(:partial =>
“goclick”)) %>");

====================================================================
correct way :
$("#allclick").html("<%= escape_javascript(render(:partial =>
“goclick”)) %>");

====================================================================
Instead of update now I’m using html

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs