Javascript Jquery对话框打开整个页面而不是特定的div标记
我有一个贯穿整个代码的通用对话框:Javascript Jquery对话框打开整个页面而不是特定的div标记,javascript,jquery,html,dialog,Javascript,Jquery,Html,Dialog,我有一个贯穿整个代码的通用对话框: <div id="dialog" style="display:none"> <img src="../images/ajax-loader.gif" align="middle" height="16px" width="16px" style="display:block;margin:auto;"/> </div> $().ready(function(){ $( "#dialog" ).d
<div id="dialog" style="display:none"> <img src="../images/ajax-loader.gif" align="middle" height="16px" width="16px" style="display:block;margin:auto;"/> </div>
$().ready(function(){
$( "#dialog" ).dialog({
autoOpen: false ,
modal : true,
dialogClass: 'fixed-dialog',
open: function(event, ui)
{ // sets width on open, then recenters on screen
//$(event.target).dialog('option', 'width', ($(event.target)[0].scrollWidth) + 'px');
//alert($(event.target)[0].scrollWidth + 50);
$(event.target).dialog('option', 'max-height', '85vh');
$('#dialog').css('overflow-x', 'hidden');
$(event.target).dialog('option', 'width', 'auto');
$(event.target).dialog('option', 'position', {my: "center", at: "center", of: window});
} ,
close: function(event, ui) {
$('#dialog').html("<div style='height:57px;width:80px;display:table-cell;vertical-align:bottom'><img src='../images/ajax-loader.gif' align='middle' height='16px' width='16px' style='display:block;margin:auto;vertical-align:middle;'/></div>");
},
});
$(document).on("ajaxStop", function (e) {
$("#dialog").dialog("option", "position", {my: "center", at: "center", of: window});
});
$(window).resize(function() {
$("#dialog").dialog("option", "position", {my: "center", at: "center", of: window});
});
});
(页面上的单击事件调用AutoCloseOrder函数)
如何编写dialog.load行来挑出特定的div标记。div标签如下所示:
<div id="close_container_wrapper" style="left:-9000px; position:absolute;" title="Close Big Order">
<table id="close_container" cellspacing="0">
<tr>
<td colspan="2">
<label for="Errmsg" id="Errmsg" style="color: red"></label></td><td> </td>
</tr>
<tr height="1">
<td colspan="3" style="line-height:1em"> </td>
</tr>
<tr>
<td><b class="header">Auto Close Order #<%=GetOrderNumberByOrderId(request("order_id"))%></b></td><td> </td>
</tr>
<tr height="20" bgcolor="<%=AlternateColors()%>">
<td><b>Balance Due:</b></td><td id="balance_due"><%=FormatCurrencyToLocale(balance_due, 2)%></td><td> </td>
</tr>
<tr height="20" bgcolor="<%=AlternateColors()%>">
<td><b>Expected Guest Count</b></td><td><%=e_guest_1%></td><td> </td>
</tr>
<% If b_guest_fees Then %>
<tr height="20" bgcolor="<%=AlternateColors()%>">
<td><b>Expected Guest Count 2</b></td><td><%=e_guest_2%></td><td> </td>
</tr>
<% End If %>
<tr height="20" bgcolor="<%=AlternateColors()%>">
<td><b>Actual Guest Count</b></td><td><input type="text" name="guest_1" id="guest_1" onblur="JavaScript:isGuestCountNotZero(this, document.getElementById('guest_1'), document.getElementById('hidGuest_1'), document.getElementById('hidChecklistDone'))" value="<%=guest_1%>"><input type="hidden" name="hidguest_1" id="hidGuest_1" value="<%=guest_1%>"></td><td><input type="button" value="Update" onclick="UpdateGuestCount('<%=b_guest_fees%>')" /></td>
</tr>
<% If b_guest_fees Then %>
<tr height="20" bgcolor="<%=AlternateColors()%>">
<td><b>Actual Guest Count 2</b></td><td><input type="text" name="guest_2" id="guest_2" onblur="JavaScript:isGuestCountNotZero(this, document.getElementById('guest_2'), document.getElementById('hidGuest_1'), document.getElementById('hidChecklistDone'))" value="<%=guest_2%>"></td><td><input type="button" value="Update" onclick="UpdateGuestCount('<%=b_guest_fees%>')" /></td>
</tr>
<% End If %>
<tr height="20" bgcolor="<%=AlternateColors()%>">
<td><b>Checklist Status</b></td><td><% If checklist_done Then Response.Write("Complete") Else Response.Write("Incomplete") End If%><input type="hidden" name="hidChecklistDone" id="hidChecklistDone" value="<%=checklist_done%>"></td><td> </td>
</tr>
<tr height="20">
<td colspan="3" style="line-height:1em"> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" nowrap>
<% If Round(CCur(balance_due), 2) = 0 Then %>
<input class="pcs_button" id="close" type="button" onmouseover="JavaScript:isGuestCountNotZero(this, document.getElementById('guest_1'), document.getElementById('hidGuest_1'), document.getElementById('hidChecklistDone'))" onClick="Pcs.CoreSupport.Browser.navigateWithReferrer('order_info.asp?order_id=<%=Request("order_id")%>&action=close_order')" value="Close Order"/>
<% End If %>
</td>
</tr>
自动关闭订单
尚欠余额:
预期客人数
预期客人数2
实际客人人数
实际客人人数2
检查表状态
此外,还将加载所有正确的jQuery库等。。。它可以与外部URL一起工作,而不是同一页面上的div标记,在这里,我认为这会更简单。最终将整个内容移出了它自己的函数,并在Ajax调用的response:success部分启动了它。这是最终起作用的代码
function CheckAutoClose(order_id) {
//alert(order_id);
var ajaxUrl = new Ajax.Request("order_info.asp", {
parameters: {
'ajax_call': 'check_order_close_status',
'order_id': order_id,
},
onSuccess: function(response){
//Ajax call is always a success because the sp always returns a result. If no response text sp returned false for closed requirements met
if (response.responseText.length >0) {
$j('#dialog').dialog({title:'Close Order'});
$j('#dialog').html(response.responseText);
$j('#dialog').dialog('open', {width:'auto'});
}
},
onFailure: Pcs.App.ajaxErrorDisplay
});
}
传递给
load()
的url无效。您是想从元素的现有版本获取html,还是发出ajax请求并检索该元素的服务器版本?发出ajax请求是我想要的方式。在此之前未加载图元。(我查看了源代码以确定)然后您需要提供url,然后是一个空间,然后选择或尝试,但仍然有问题。它现在的内容是:$('#dialog').load('order_info.asp#close_container_wrapper').html代码>但无法加载任何内容。chrome中的控制台报告一个错误,表示该位置不存在。
</div>
function CheckAutoClose(order_id) {
//alert(order_id);
var ajaxUrl = new Ajax.Request("order_info.asp", {
parameters: {
'ajax_call': 'check_order_close_status',
'order_id': order_id,
},
onSuccess: function(response){
//Ajax call is always a success because the sp always returns a result. If no response text sp returned false for closed requirements met
if (response.responseText.length >0) {
$j('#dialog').dialog({title:'Close Order'});
$j('#dialog').html(response.responseText);
$j('#dialog').dialog('open', {width:'auto'});
}
},
onFailure: Pcs.App.ajaxErrorDisplay
});
}