Ismoh
Ismoh

Reputation: 1104

Ruby on Rails - link_to - quotes in class

This is what I want:

class = "navbar-toggle" data-toggle = "collapse" data-target = ".navMenuCollapse"

This is what I got:

class="\"navbar-toggle\" data-toggle = \"collapse\" data-target = \".navMenuCollapse\""

This is what I tried:

<%= link_to 'test', welcome_index_path, {:class => '\"navbar-toggle\" data-toggle = \"collapse\" data-target = \".navMenuCollapse\"'} %>

Is there any opportunity to get quotes in the class-tag ? Thanks for help.

Upvotes: 1

Views: 227

Answers (2)

Saravanan
Saravanan

Reputation: 509

Try the below code:

<%= link_to 'test', welcome_index_path, class: 'navbar-toggle', data: {toggle: 'collapse', target: '.navMenuCollapse'} %>

Upvotes: 6

Marek Lipka
Marek Lipka

Reputation: 51151

This should work:

<%= link_to 'test', welcome_index_path, :class => 'navbar-toggle', :'data-toggle' => 'collapse', :'data-target' => '.navMenuCollapse' %>

Upvotes: 1

Related Questions