3
我想在我的社交網站上添加一個阻止用戶/取消阻止用戶。我可以讓它阻止用戶或解除阻止,但是一旦鏈接的div刷新鏈接將不再顯示對話框,所以基本上鍊接在刷新時變爲死亡。jquery刷新div後鏈接不工作
// Block user
$(document).ready(function() {
$('#bottomcontain').append('<div id="blockconfirm"></div><div id="unblockconfirm"></div><div id="blockmsg"></div>');
sentTime = null;
function startTimer() {
sentTime = window.setTimeout(function() { $("#blockmsg").dialog('close'); }, 3000);
}
$("#blockmsg").dialog({
autoOpen: false,
draggable: false,
resizable: false,
model: true,
title: 'Block Settings Changed',
open: function() {
clearTimeout(sentTime);
startTimer();
},
buttons: {
"Ok": function() {
$('#blockmsg').dialog('close');
}
}
});
$('#blockconfirm').dialog({
autoOpen: false,
draggable: false,
resizable: false,
modal: true,
title: 'Block User',
buttons: {
"Yes": function() {
$.ajax({
type: 'POST',
url: 'windows.php?method=blockuser',
dataType: 'json',
data: {
block_id: profile
},
success: function(data){
if(data.error == false){
$('#blockconfirm').dialog('close');
$('#blockarea').load('profile.php?uid=' + profile + ' #unblockuser');
$('#blockmsg').load('windows.php?method=blockmsg1').dialog('open');
}
if(data.error == true){
$('#blockerr').html(' '+ data.msg).removeClass().addClass('ui-state-error').show(500);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#blockerr').removeClass().addClass('ui-state-error').text('There was an error.').show(500);
}
});
return false;
},
"No": function() {
$('#blockconfirm').dialog('close');
}
}
});
$('#unblockconfirm').dialog({
autoOpen: false,
draggable: false,
resizable: false,
modal: true,
title: 'Unblock User',
buttons: {
"Yes": function() {
$.ajax({
type: 'POST',
url: 'windows.php?method=unblockuser',
dataType: 'json',
data: {
block_id: profile
},
success: function(data){
if(data.error == false){
$('#unblockconfirm').dialog('close');
$('#blockarea').load('profile.php?uid=' + profile + ' #blockuser');
$('#blockmsg').load('windows.php?method=blockmsg2').dialog('open');
}
if(data.error == true){
$('#blockerr').html(' '+ data.msg).removeClass().addClass('ui-state-error').show(500);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#blockerr').removeClass().addClass('ui-state-error').text('There was an error.').show(500);
}
});
return false;
},
"No": function() {
$('#unblockconfirm').dialog('close');
}
}
});
$('#blockuser').click(function() {
$('#blockconfirm').load('windows.php?method=blockconfirm').dialog('open');
return false;
});
$('#unblockuser').click(function() {
$('#unblockconfirm').load('windows.php?method=unblockconfirm').dialog('open');
return false;
});
});
好吧,讓它工作使用現場。非常感謝,現在一直在研究這個問題。 – Bobby 2011-03-23 20:01:31
您可以將此標記爲您問題的答案。 – 2011-03-24 07:04:39