oh ok :) Thanks for taking time to answer :)
So now i got this, it works but it sends the ajax calls twice. is it
maybe because i set the callback wrong? the callback argument gets:
function() { fGbDelete(gbid,link); }
Shouldn´t it get just: fGbDelete(gbid,link)? Or why is it triggering
twice?
function dialogBox(type,blockUi,heading,message,callback) {
var result;
var signImg;
var buttons;
var ok = '<div><input type="button" id="okBtn" value="Ok" /></div>';
var no = '<div><input type="button" id="noBtn" value="Avbryt" /></
div>';
//warning dialogbox
if (type=='warning' || type=='') {
signImg='_img/signs/warning.png';
buttons=ok+no;
}
//Info dialogbox
else if (type == 'info') {
signImg = '_img/signs/info.png';
buttons = ok;
}
//Fatal dialogbox
else {
signImg = '_img/signs/error.png';
buttons = ok;
}
//Create dialogbox
function dialogBoxCreation() {
$('<div id="dialogBox"><img src="'+signImg+'" alt="sign" /
><h3>'+heading+'</h3><p>'+message+'</p>'+buttons+'</div>')
.appendTo('body')
.center()
.hide()
.fadeIn();
}
dialogBoxCreation();
//BlockUi
if (blockUi=='yes') {
$('<div id="dialogBg"></div>').height($('body').height()).width
('100%').css({
'position': 'absolute',
'background': '#000',
'opacity': '0.6',
'z-index': '1'
}).prependTo('body').fadeIn();
}
alert(callback);
$('#dialogBox').click(function(e) {
var tgt = $(e.target);
if (tgt.is('#okBtn')) {
$('#dialogBox,#dialogBg').fadeOut(function() {
$('#dialogBox').remove();
$('#dialogBg').remove();
callback();
});
}
else if (tgt.is('#noBtn')) {
$('#dialogBox,#dialogBg').fadeOut(function() {
$('#dialogBox').remove();
$('#dialogBg').remove();
});
}
else {}
});
}
function fGbDelete(gbid,link) {
var gbSplit = gbid.split(',');
$.ajax({
type: "POST",
url: "_scripts/send_message.php",
data: "action=delete_gb& gbid=" + gbSplit[0],
beforeSend: function() {
$(link).parent().fadeOut(1200);
},
success: function() {
//$(".gb_message:first").before("<div
id='sending'><div>");
setTimeout(function() {
$("#gbPosts").load("_members/gb_posts.php?
funk&userID=" + gbSplit[1]);
$.getScript('_scripts/sc_functions.js');
},1200);
$("#gb_post").attr("value", "");
}
});
}
//User clicks delete link
$(document).ready(function() {
$('a#deleteGb').live('click',function(e) {
var link = $(this).parent();
var gbid = $(this).attr("href");
dialogBox('warning','yes','Varning','Är du säker på att du
vill radera inlägget?',function() {
fGbDelete(gbid,link);
});
return false;
});
});
Thanks :)
George