Search code examples
ruby-on-railstwitter-bootstrapruby-on-rails-4bootstrap-modallink-to

Rails 4: add multiple data-toggle inside link_to helper


In my Rails 4 app, inside my views, I use a lot of link_to helpers.

When I need to add a Bootstrap tooltip to a link, I do:

<%= link_to "Link text", model_path(@model), "data-toggle" => "tooltip", "data-placement" => "bottom", "title" => "Model View" %>

And, when I need to add a Bootstrap modal to a link, I do:

<%= link_to  "Link text", model_path(@model), :remote => true, 'data-toggle' =>  "modal", 'data-target' => '#modal-window' %>

Now, in one particular place in my app, I need to add BOTH a tooltip AND a modal on the same link.

I have found two Stack Overflow questions, here and there, which explain how to add several data-toggle attributes in Rails, but none of them offers a solution to implement this INSIDE a link_to helper.

Is that actually possible?


Solution

  • I don't think you can, but could you just wrap your link in a <div> or a <span> and put the tool tip on that.