大佬教程收集整理的这篇文章主要介绍了jquery – 关闭时重置模态对话框,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<div id="password-form" title="Reset password"> <form method="post"> <fieldset> <label for="emailreset">Enter Email Address</label> <input type="text" name="emailreset" id="emailreset" class="text ui-widget-content ui-corner-all" /> </fieldset> </form> </div>
当用户点击重置密码按钮时,我会调用一个检查用户是否存在的功能.
在帖子成功后,我将div的内容更改为生成的消息.
所有这些都按预期工作.现在我想要发生的是一旦关闭模态对话框,我希望内容重置回到表单.我遇到了让这件事发生的问题.
这是我对jquery的看法
$( "#password-form" ).dialog({ autoOpen: false,height: 200,width: 300,modal: true,buttons: { "Reset password": function() { $.ajax({ url: "/model/websitemanager.cfc",type: "post",dataType: "html",data: { method: "resetpassword",emailreset: $("#emailreset").val() },success: function (data){ //alert(data); $('#password-form').html('<p>'+data+'</p>'); } // this runs if an error,error: function (xhr,textStatus,errorThrown){ // show error alert(errorThrown); } }); <!--//end ajax call//--> },},close: function() { emailreset.val( "" ).removeClass( "ui-state-error" ); $(this).dialog('destroy').remove() } });
function clearInputs(target) { $(target).find(':input').each(function () { switch (this.typE) { case 'password': case 'SELEct-multiple': case 'SELEct-one': case 'text': case 'textarea': $(this).val(''); break; case 'checkBox': case 'radio': this.checked = false; } }); }
以下是我如何将它用于jQuery对话框:
$('#myDialog').dialog({ buttons:{ 'Submit':function () { // Do something here clearInputs($(this).find('form')); $(this).dialog('close'); },'Cancel':function () { clearInputs($(this).find('form')); $(this).dialog('close'); } },close:function () { clearInputs($(this).find('form')); } });
以上是大佬教程为你收集整理的jquery – 关闭时重置模态对话框全部内容,希望文章能够帮你解决jquery – 关闭时重置模态对话框所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。