不填充模态视图

时间:2013-06-03 06:31:53

标签: ruby-on-rails ruby twitter-bootstrap

所以基本上,我想用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%

2 个答案:

答案 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>'