Reputation: 2662
So basically, I want to populate the twitter bootstrap with the Ruby on Rails looping over the hash of records:
var popup = '<div id='+ key +' class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
'<div class="modal-body">'+
<% v.each_with_index do |s, i| %>
<%= i %>
<% end %>
'</div>' +
'<div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Close</button></div>' + '</div>'
$(popup).appendTo("body");
However it gives me only the first element... 0
PS the date is 100% in the hash
Upvotes: 0
Views: 109
Reputation:
Change it to
var popup = '<div id='+ key +' class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' + '<div class="modal-body">'
<% v.each_with_index do |s, i| %>
popup = popup + <%= i %>
<% end %>
popup = popup + '</div>' + '<div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Close</button></div>' + '</div>'
Upvotes: 1
Reputation: 4315
You have missed (probably mistyped) :
<%= v.each_with_index do |s, i| %>
if you'd like to run Ruby statement in your .erb
template.
Upvotes: 1