所以基本上,我想用Ruby on Rails填充twitter引导程序循环遍历记录的哈希:
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>'
$(弹出).appendTo( “身”);
然而它只给我第一个元素...... 0
PS哈希
中的日期为100%答案 0 :(得分:1)
你错过了(可能是错误的):
<%= v.each_with_index do |s, i| %>
如果您想在.erb
模板中运行Ruby语句。
答案 1 :(得分:1)
将其更改为
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>'