這裏是我的代碼按鈕在那裏時div不會被隱藏,爲什麼?
if(userid == ""){
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
resizable: false,
height: 230,
width: 350,
modal: true,
buttons: {
"Register": function(){
$(this).dialog("close");
$('div#registerpopup').dialog({
resizable: false,
height: 485,
width: 420,
modal: true,
buttons: {
"Register" : function(){
var valid = true;
valid = valid && checkLength(username,"Username",1,30);
valid = valid && checkPassword(password,"Password",7,);
valid = valid && checkRetype(password,retypepassword);
valid = valid && checkRegexp(emailaddress,emailRegex,"Emailaddress");
valid = valid && checkSecretquestion(secretquestion,"Secret Question");
valid = valid && checkSecretquestion(secretanswer,"Secret Answer");
if(valid){
$.ajax({
type: "POST",
url: "classes/ajax.registerpopup.php",
timeout: 8000,
data: "username="+username+"&password="+password+"&emailaddress="+emailaddress+
"&secretquestion="+secretquestion+"&secretanswer="+secretanswer,
success: function(){
alert("you are registered now");
}
});
return false;
}
}
}
});
},
"Log in": function() {
$(this).dialog("close");
$('div#loginpopup').dialog({
resizable: false,
height: 230,
width: 350,
modal: true
})
}
}
});
return false;
}
這就是所謂隱藏的div
<div id="dialog-confirm" title="Register OR Login">
<p>Before you can submit your cv,<br />please log in or register,registering only takes 2 seconds
and you will not lose the information you have entered.</p>
</div>
和
<div id="registerpopup" title="Register" class="form" style="background: #F0F0F0;">
<p class="validateTips">All form fields are required.</p>
<form>
<table>
<tr>
<td><label>Username</label></td>
<td><input type="text" name="username" id="username" size="12"/></td>
</tr>
<tr>
<td><label>Password</label></td>
<td><input type="password" name="password" id="password" size="10" value=""/></td>
</tr>
<tr>
<td><label>Re-type Password</label></td>
<td><input type="password" name="retypepassword" id="retypepassword" size="10" value=""/></td>
</tr>
<tr>
<td><label>Email Address</label></td>
<td><input type="text" name="emailaddress" id="emailaddress" value=""/></td>
</tr>
<tr>
<td><label>Secondary Email Address</label></td>
<td><input type="text" name="secondaryemailaddress" id="secondaryemailaddress" value=""/></td>
</tr>
<tr>
<td><label>Secret Question</label></td>
<td><input type="text" name="secretquestion" id="secretquestion" value="" /></td>
</tr>
<tr>
<td><label>Secret Answer</label></td>
<td><input type="secretanswer" name="secretanswer" id="secretanswer" value=""/></td>
</tr>
<tr>
<td><label>Reff. Code</label></td>
<td><input type="text" name="reffcode" id="reffcode" value="" /></td>
</tr>
</table>
</form>
</div>
現在我的問題是,爲什麼它的所謂隱藏層出現的時候,我把$('div#registerpopu).dialog({})的按鈕參數? ,但當按鈕不在那裏,divs被隱藏,我錯過了什麼?
在對話框中:autoopen:false,我認爲你需要如果我理解你的問題。 – abhijit
你看到這部分? ''Register':function(){ var valid = true; valid = valid && checkLength(username,「username」,1,30);'等等。? ,這就是指的是,當按鈕在那裏時,應該隱藏的div會顯示在網頁上,但是如果我評論按鈕,它們會隱藏 – sasori
默認情況下通過設置'autoOpen:false'來隱藏對話框。並且可能在您的按鈕配置中存在一些語法錯誤,請嘗試查看是否有任何錯誤在瀏覽器的js控制檯中彈出。 – Quincy