\'flowtracker\', :with=>\"\'topcount=\'+$(\'topcount\').value," />
开发者

how do specfiy :with attribute in rails 3 link_to

开发者 https://www.devze.com 2023-03-22 17:48 出处:网络
This is link_to_remote code for rails 2.3.8 link_to_remote \"Click here\", :update=>\'flowtracker\', :with=>\"\'topcount=\'+$(\'topcount\').value,

This is link_to_remote code for rails 2.3.8

link_to_remote "Click here",

:update=>'flowtracker',

:with=>"'topcount='+$('topcount').value,

:url=>{ :controller => 'sessions',

:action => 'session_for_tracker',

:layout=>1 }

link_to_remote deprecated in rails 3

so 开发者_JAVA技巧how can i specify the :with attribute in link_to rails 3

And i'm using prototype.js


Use link_to helper with :remote => true option and do whatever you want in your js view file to your action.

EXAMPLE

in view:

<%= link_to 'ajax call', :controller => "sessions", :action => "session_for_tracker", :remote => true %>

in controller:

def session_for_tracker
  @topcount = 1000; #get actual value here

  respond_to do |format|
    format.js
  end
end

in js view for action:

page << %|
  $('flowtracker').update("#{@topcount}");
|
0

精彩评论

暂无评论...
验证码 换一张
取 消