Jquery 表中的Ajax响应将失去对Modal的访问
内容加载良好,页面刷新为动态内容。然而,正在加载的内容包括一个链接,用于触发具有适当内容的模态。单击链接后,我将进入一个新页面,其中包含应在模式中加载的内容。当我不通过Ajax注入内容时,触发模式工作正常 查看源页面时,我看不到源页面中显示的远程内容。除了表/div中的Jquery 表中的Ajax响应将失去对Modal的访问,jquery,ajax,twitter-bootstrap-3,bootstrap-modal,Jquery,Ajax,Twitter Bootstrap 3,Bootstrap Modal,内容加载良好,页面刷新为动态内容。然而,正在加载的内容包括一个链接,用于触发具有适当内容的模态。单击链接后,我将进入一个新页面,其中包含应在模式中加载的内容。当我不通过Ajax注入内容时,触发模式工作正常 查看源页面时,我看不到源页面中显示的远程内容。除了表/div中的tbody是空的之外,我看到了其他所有内容 正在加载的页面具有此链接 <a href="/host/{{ $k->hostname }}/log/{{ $k->job_id }}" rel=&
tbody
是空的之外,我看到了其他所有内容
正在加载的页面具有此链接
<a href="/host/{{ $k->hostname }}/log/{{ $k->job_id }}" rel="modal"><button type="button" class="btn btn-link"><i class="icon-file-text position-left"></i></button></a>
<div id="refreshme">
<table>
<tbody></tbody>
</table>
</div>
<div id="modal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-info">
<button type="button" class="close" data-dismiss="modal">×</button>
<h6 class="modal-title" id="sam"></h6>
</div>
<div class="modal-body">
<!-- /# content goes here -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
$(function() {
startRefresh();
});
function startRefresh() {
var environment_id = "{{ $deployment_info->environment_id }}";
var job_id = "{{ $job_id }}";
setTimeout(startRefresh,1000);
$.get('/deploys/' + environment_id + '/info_div/'+ job_id, function(data) {
$('#refreshMe tbody').html(data);
});
}
// Modal code
$('a[rel=modal]').on('click', function(evt) {
evt.preventDefault();
var modal = $('#modal').modal();
modal
.find('.modal-body')
.load($(this).attr('href'), function (responseText, textStatus) {
if ( textStatus === 'success' ||
textStatus === 'notmodified')
{
modal.show();
}
});
});