开发者

how do you render a js.erb file with a link?

Let's say you have a link like this:

<%= link_to "Add Topics", ???, :remote => true, :id => 'edit_topics开发者_C百科_link' %>

What do you put where the ??? is to render a js.erb file in the same directory?


You should have an action in your controller which responds_to with format.js and the route for it.

def action
  ...
  respond_to do |format|
    format.js {}
  end
end

the in routes

resources :something do
  member do
    get or post :action, :as => :blah
  end
end

Then if you run rake routes you will see something like blah_something_path which you can use in link_to

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜