我有一個鏈接如下:如何從超鏈接調用jQuery中的另一個函數?
<div id="demo-testpack">
<a href="#" class="user-not-loggedin">Demo Test Packages</a>
</div>
在點擊這個鏈接我打電話以下的jQuery代碼上:
$(function() {
$("#user-popup-login").dialog({ autoOpen: false });
$(".user-not-loggedin")
.click(function() {
$("#user-popup-login").dialog("option", "width", 400);
$("#user-popup-login").dialog("option", "modal", true);
$("#user-popup-login").dialog("open");
return false;
});
的彈出獲取此功能的一些領域和一些開後鏈接在彈出。其中一個環節是,在彈出如下:
<div id="registern"><a href="#" class="register-btn">Register Now</a></div>
在這個環節我想執行以下代碼導致另一個彈出的開放的點擊。這樣做的jQuery代碼如下:
$(function() {
$("#create-user-form").dialog({ autoOpen: false });
$(".register-btn")
.click(function() {
$("#create-user-form").dialog("option", "width", 560);
$("#create-user-form").dialog("option", "modal", true);
$("#create-user-form").dialog("open");
return false;
});
$(".get-start")
.click(function() {
$("#create-user-form").dialog("option", "width", 560);
$("#create-user-form").dialog("option", "modal", true);
$("#create-user-form").dialog("open");
return false;
});
//This function is used to submit User Registration form
$('#user_registration_form').live('submit', function() {
$('.register').attr('disabled', 'disabled');
show_request('#registration_error');
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data:$(this).serialize(),
dataType: 'json',
success: function(response) {
$('.register').removeAttr('disabled', 'disabled');
var reg_error = response.reg_error;
if(reg_error=='yes') {
var error_msg = response.error_msg;
var dialog_title = 'Input Errors Found';
var dialog_message = error_msg;
$("#registration_error").html(error_msg);
} else {
$("#registration_error").html('');
$("#create-user-form").dialog('close');
var suc_msg = response.suc_msg;
var dialog_title = 'Registered Successfully';
var dialog_message = suc_msg;
var $dialog = $("<div class='ui-state-success'></div>")
.html("<p class='ui-state-error-success'>"+dialog_message+"</p>")
.dialog({
autoOpen: false,
modal:true,
title: dialog_title,
width: 500,
buttons:{
'OK': function() {
$(this).dialog('close');
}
}
});
$dialog.dialog('open');
$('#user_registration_form')[0].reset();
}
}
});
return false;
});
});
現在我想達到的目標是,當用戶點擊上面的鏈接之前打開彈出窗口應關閉,只有這個新的彈出窗口應顯示。我做了很多技巧,但沒有成功。任何人都可以幫助我瞭解如何實現這一點?在此先感謝。
聽起來像一個故事! :D – Alvaro
jsfiddle也許? –
@roasted:@roasted:你能用可行的代碼解釋我嗎? – PHPLover