我有以下文件
_result.html.erb
_show.html.erb
_show.js.erb我在_result部件中放了一个按钮,它应该在一个模态中打开_show部分。但是,当用户单击链接时,它只显示一个条形图,而不是包含。我是不是错过了手术的一部分?在我发现的教程中,这似乎相当容易。我的代码如下:
_show.html.erb
<div id="modal-window" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<h3 class="section_title">
Hello this is the Show modal
</h3>
</div>
</div>
</div>_result.html.erb (位于Welcome.html.erb中)
<div id="modal-window" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content"></div>
</div>
</div>show.js.erb
$("#modal-window").find(".modal-content").html("<%= j (render 'invitations/show') %>");
$("#modal-window").modal('show');我现在得到的只是一条线:

有人知道为什么包含没有显示,尽管我确实使用了相同的标签和id标签在rails中创建Kolosek模式控制器:
def show
@invitation = Invitation.find(params[:id])
respond_to do |format|
format.html
format.js {render :layout => false}
end
end发布于 2018-11-07 06:05:07
我看到您正在按照https://qiita.com/Kolosek/items/4ee80eb0c6dd0af4b1b7教程创建一个模型,但是您的代码是不正确的!您正在尝试在另一个模态中显示一个模态,而应该在该模态中显示其内容。将_show.html.erb修改为下面
#_show.html.erb
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">x</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
*Modal content comes here*
</div>
<div class="modal-footer">
<button class="btn btn-primary">Save</button>
</div>https://stackoverflow.com/questions/53183429
复制相似问题