Javascript JQuery UI对话框html()和fadein崩溃
我使用的是dialog jquery UI,当用户提交正确的输入时,我会应用html和fadein。当DOM读到这一行时,它崩溃了,我尝试调试器,它崩溃在这一行,我不知道为什么,因为在它像一个符咒一样工作之前。控制台在使用chrome最新版本时不会向我抛出任何错误或警告:Javascript JQuery UI对话框html()和fadein崩溃,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我使用的是dialog jquery UI,当用户提交正确的输入时,我会应用html和fadein。当DOM读到这一行时,它崩溃了,我尝试调试器,它崩溃在这一行,我不知道为什么,因为在它像一个符咒一样工作之前。控制台在使用chrome最新版本时不会向我抛出任何错误或警告: ("#myform").hide().html("<span class='modalok glyphicon glyphicon-ok'></span><p class='modalsucces
("#myform").hide().html("<span class='modalok glyphicon glyphicon-ok'></span><p class='modalsuccessp'>¡Muchas gracias!</p>").fadeIn('slow');
setTimeout(function(){
$('#dialog').dialog('close')
}, 2000)
对话框的HTML结构:
<div id="message" class="row-fluid hidden"></div>
<div id="page" class="row-fluid"><div class="page-header"><div id="dialog" style="display: none;" title="Task detail">
<div class="modal-body">
<div class="row-fluid" style="padding-bottom: 0px;">
<form class="form-horizontal" id="myform" novalidate="">
<div class="control-group">
<label class="control-label" for="email">Email address</label>
<div class="controls">
<input type="email" class="form-control" name="email" id="email" required="" aria-invalid="true">
</div>
</div>
<div class="control-group error">
<label class="control-label" for="emailAgain">Email again</label>
<div class="controls">
<input type="email" data-validation-matches-match="email" data-validation-matches-message="Must match email address entered above" class="form-control" id="emailAgain" name="emailAgain" aria-invalid="false">
</div>
</div>
<div class="control-group">
<label class="control-label" for="terms-and-conditions">Legal</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" id="terms-and-conditions" name="terms-and-conditions" required="" data-validation-required-message="You must agree to the terms and conditions" aria-invalid="true">
I agree to the <a href="#">terms and conditions</a>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">Quality Control</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="qualityControl[]" value="fast" data-validation-minchecked-minchecked="2" data-validation-minchecked-message="Choose two" data-validation-maxchecked-maxchecked="2" data-validation-maxchecked-message="You can't have it all ways" aria-invalid="true">
Fast
</label>
<label class="checkbox">
<input type="checkbox" name="qualityControl[]" value="cheap" aria-invalid="false">
Cheap
</label>
<label class="checkbox">
<input type="checkbox" name="qualityControl[]" value="good" aria-invalid="false">
Good
</label>
</div>
</div>
<div class="modal-footer">
<button id="btnSave" type="submit" class="btn btn-success modalbtn">Guardar cambios</button>
<button id="btnClose" type="button" class="btn btn-default modalbtn cancel" data-dismiss="modal">Cerrar</button>
</div>
</form>
</div>
</div> </div>
JQuery结构:
$('input,textarea').jqBootstrapValidation(
{
submitError: function ($form, event, errors) {
$('#btnSave')[0].disabled = false;
$("#myform").effect( "shake" );
}
}
);
$('input,textarea').jqBootstrapValidation(
{
submitSuccess: function ($form, event, errors) {
$('#btnSave')[0].disabled = false;
$("#myform").hide().html("<span class='modalok glyphicon glyphicon-ok'></span><p class='modalsuccessp'>¡Muchas gracias!</p>").fadeIn('slow');
setTimeout(function(){
$('#dialog').dialog('close')
}, 2000)
}
}
);
验证工作正常,不正确时会震动,但当我单击“保存更改和所有正确的SubmitAccess”功能时,会崩溃并关闭对话框…我不知道问题出在哪里,但您可以尝试一下
$("#myform").hide().html("<span class='modalok glyphicon glyphicon-ok'></span><p class='modalsuccessp'>¡Muchas gracias!</p>").fadeIn('slow', function() {
setTimeout(function() {
$('#dialog').dialog('close')
}, 2000)
});
从你的html代码中,我不确定你是想显示对话还是在成功后淡出对话。但是我用你的代码创建了一个小提琴,效果很好。成功验证后,它会在muchas gracias中消失!消息我更新了js代码如下:
$(document).ready(function(){
$('input,textarea').jqBootstrapValidation(
{
submitError: function ($form, event, errors) {
$('#btnSave')[0].disabled = false;
$("#myform").effect( "shake" );
},
submitSuccess: function ($form, event,errors) {
$('#btnSave')[0].disabled = false;
event.preventDefault();
$("#myform").hide().html("<span class='modalok glyphicon glyphicon-ok'></span><p class='modalsuccessp'>¡Muchas gracias!</p>").fadeIn('slow');
setTimeout(function(){
$('#dialog').dialog('close')
}, 2000)
}
}
);
});
检查小提琴,使用它的代码,如果它停止崩溃,请告诉我
现在我停止崩溃,如果它再次崩溃,我会很快告诉你。谢谢!!编辑:我不知道为什么当我点击按钮打开模式时,我会滚动到页面底部,而模式在顶部。。。检查这个