Uday kumar das
Uday kumar das

Reputation: 1613

syntax to use `data-toggle` and `data-target` in link_to rails 4

I have:

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

In this link i want to use data-toggle="modal" and data-target="#myModal1".Please tell me the right syntax for it.

Upvotes: 2

Views: 6461

Answers (1)

makhan
makhan

Reputation: 4009

These are link_to signatures:

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

You want them to end up in html_options block. Try:

<%= 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 %>

Or:

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

Upvotes: 2

Related Questions