语法使用`中的link_to导轨4数据toggle`和`数据target`(syntax to us

2019-10-22 02:44发布

我有:

<%= link_to :action=>'view_score_card',:id=>innings1_batting_datail.id,remote: true,:class=>"body_inner_icon" do %>

在这个环节我想用data-toggle="modal"data-target="#myModal1" 。请告诉我正确的语法它。

Answer 1:

这些link_to签名:

link_to(body, url, html_options = {})
link_to(body, url_options = {}, html_options = {})
link_to(options = {}, html_options = {})
link_to(url, html_options = {})

你希望他们在html_options块结束。 尝试:

<%= link_to 'link', {:action => 'view_score_card', :id => innings1_batting_datail.id}, {:remote => true, :class => "body_inner_icon", 'data-target' => "#myModal1", 'data-toggle' => "modal"} do %>

要么:

<%= link_to 'link', view_score_card_path(innings1_batting_datail), {:remote => true, :class => "body_inner_icon", 'data-target' => "#myModal1", 'data-toggle' => "modal"} do %>


文章来源: syntax to use `data-toggle` and `data-target` in link_to rails 4