Reddirt
Reddirt

Reputation: 5953

Rails adding class to content_tag_for :li

The following index code works fine:

  <ul id="sortable1" class="connectedSortable" data-update-url="<%= sort_tasks_url %>">
<% current_user.tasks.each do |task| %>
      <%= content_tag_for :li,  task do %>
            <%= task.taskstatus.statuscode %>
            <%= " - " %>
            <%= link_to h(task.taskname), task %>
            <%= " - " %>
            <%= task.taskdesc %>
        <% end %>
<% end %>

But, I can't figure out how to add a class to each li line. I get a syntax error with this:

<%= content_tag_for(:li, :class => 'ui-state-highlight'),  task do %>

Thanks for the help!

Upvotes: 1

Views: 901

Answers (1)

Reddirt
Reddirt

Reputation: 5953

Figured it out:

<%= content_tag_for( :li, task, :class => "ui-state-highlight") do %>

Upvotes: 2

Related Questions