我想显示模态窗口的点击链接,但也想做ajax请求,以获得对象,需要显示在模态窗口。
我得到响应的内容,需要显示在模态窗口,但它没有弹出作为模态窗口,可能脚本没有被执行。
代码
主页
<%= link_to "New Topic", "#", :class => 'btn primary float-right bootstrap-popover' %>
<div id="modal_form_container"></div>Javascript代码
$('a.bootstrap-popover').live('click', function(){
$(this).unbind('click');
$.ajax({
url: "/topics/new",
type: "GET",
dataType: "html",
complete: function() {
$('loading').hide();
},
success: function(data) {
},
error:function() {
}
}); // End of Ajaxnew.js.erb
$('#modal_form_container').html("<%= escape_javascript( render :partial => 'new_form')%>");
$('#modal_form').modal('show'); 此new_form页面包含将显示在模式窗口上的内容。
有人能帮忙吗?
发布于 2011-12-12 14:28:57
是因为加载元素没有被隐藏吗?
$('loading').hide();如果不是这样的话:
$('#loading').hide();发布于 2011-12-24 11:41:01
我认为,在ajax请求成功之后,您必须编写类似于以下代码的代码。
$('#PopupBoxId').modal('show'); // Show the pop-up (modal)
$('#disable_layer').modal('show'); // Show the black overlay我们必须在ajax请求处理之后手动显示弹出。根据我在鞋带方面的小经验。:)
希望它对你有用。
发布于 2012-12-05 03:00:36
你查过自举模态管理器了吗?您可以这样使用它:
$("a.open-with-ajax-loader").live('click', function(e){
e.preventDefault();
$('body').modalmanager('loading');
$('#id-of-modal-div').modal({
remote: '/url/to/load'
});
});您可以在引导模式管理器的现场演示页面上看到这一点(向下滚动,查找AJAX演示)。
https://stackoverflow.com/questions/8475255
复制相似问题