我的页面有多个对话框。我为它定义了单独的 div 部分。根据要求,我必须禁用对话框中的保存按钮,直到未填充所有必填字段。我能够禁用它。当我打开其他对话框时出现问题。这些对话框的保存按钮也被禁用。
我可以在我不想这样做的对话框上放置脚本以启用按钮。我有其他解决方案来解决这个问题吗?
我的页面.cshtml
<div id="MyDialg" title="Dialog 1">
</div>
<input id="btnMy" type="button" value="Dialog1" />
MyJs.JS
$('#MyDialg').dialog({
autoOpen: false,
width: 400,
height: 350,
modal: true,
resizable: false,
buttons: {
"Cancel": function () { $(this).dialog("close"); },
"Save": function () {
}
}
});
$("#btnMy").button().live("click", function () {
var diag = $('#MyDialg');
diag.load("Action/Controller", '', function () {
});
$(diag).dialog('open');
return false;
});
我在加载时使用以下行来禁用对话框上的“保存”按钮:
_MyDialog.cshtml
$(".ui-dialog-buttonpane button:contains('Save')").button("enable");
源代码(对话框 html 之一)
<DIV class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" jQuery17205878367688005092="61" sizcache04606232417093721="71" sizset="0"><SPAN id=ui-dialog-title-MyDialg1 class=ui-dialog-title jQuery17205878367688005092="62">MyDialg title</SPAN><A class="ui-dialog-titlebar-close ui-corner-all" role=button href="#" jQuery17205878367688005092="60"><SPAN class="ui-icon ui-icon-closethick" jQuery17205878367688005092="63">close</SPAN></A></DIV>
<DIV style="MIN-HEIGHT: 0px; WIDTH: auto; HEIGHT: 247px" id=MyDialg1 class="ui-dialog-content ui-widget-content" jQuery17205878367688005092="58" scrolltop="0" scrollleft="0">
<FORM id=form1 method=post action=/action1/controllername jQuery17205878367688005092="172" novalidate="novalidate" data-ajax-success="showSuccessMessage" data-ajax-method="POST" data-ajax="true" data-ajax-failure="showErrorMesage">
<BR>
<DIV class=field><LABEL for=Name>Description: </LABEL><SUP class=mandatory>*</SUP> <INPUT id=Name class="text-box single-line" type=text name=Name> <BR><SPAN class=field-validation-valid data-valmsg-replace="true" data-valmsg-for="Name"></SPAN></DIV><BR><BR>
<HR>
<BR>
</FORM><BR></DIV>
<DIV class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" sizcache04606232417093721="71" sizset="1">
<DIV class=ui-dialog-buttonset sizcache04606232417093721="71" sizset="1"><BUTTON aria-disabled=false class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role=button type=button jQuery17205878367688005092="64"><SPAN class=ui-button-text>Cancel</SPAN></BUTTON><BUTTON aria-disabled=true class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button-disabled ui-state-disabled" role=button disabled type=button jQuery17205878367688005092="65"><SPAN class=ui-button-text>Save</SPAN></BUTTON></DIV></DIV>