Reputation: 19
first my english not good so much. sory.
my problem is, when page load complete. i use click function first clik working successfully. but secon click not working. but i refresh the page first clik working , second not working againg. when i refresh the page code is working for once. (note: i am new at jquery )
$(document).ready(function () {
$('#silmesaji').hide();
$(".delbutton").click(function () {
var element = $(this);
var silinecek_idi = element.attr("id");
var info = 'id=' + silinecek_idi;
$("#silmesaji").dialog({
modal: true,
title: 'Kategoriyi Silin!',
resizable: false,
'buttons': {
"Sil": function () {
$.ajax({
type: "GET",
url: "forms/joker.asp",
data: info,
success: function () { }
});
$("#silmesaji").dialog("close");
element.parents(".siralagayri").animate({
backgroundColor: "#f31e1f"
}, "fast").animate({
opacity: "hide"
}, "slow");
},
"iptal": function () {
$("#silmesaji").dialog("close");
}
}
});
});
firts thanks for answer.
but i want: when click OK button. sent post and close dialog. it can not work :(
$(".delbutton").click(function () {
var element = $(this);
var silinecek_idi = element.attr("id");
var info = 'id=' + silinecek_idi;
$("#silmesaji").dialog('open');
});
$("#silmesaji").dialog({
autoOpen: false,
modal: true,
buttons: {
"Ok": function() {
$.ajax({
type: "GET",
url: "forms/joker.asp",
data: info,
success: function(){
element.parents(".siralagayri")
.animate({
backgroundColor: "#f31e1f"
}, "fast")
.animate({
opacity: "hide"
}, "slow");
$("#silmesaji").dialog("close"); return false();
}
});
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
Upvotes: 1
Views: 2648
Reputation: 52518
When calling $("#silmesaji").dialog(...)
, the default for the "autoOpen" option is true
, so you create & show the dialog.
But after closing it, a call to $("#silmesaji").dialog(...)
, will not re-create the dialog, so it will also not "autoOpen".
You need to call $("#silmesaji").dialog('open')
, to re-open/show the dialog.
I always do it like this:
ready
function, I create the dialog, with autoOpen: false.
(Note: not in the click event)$("#silmesaji").dialog('open');
I will try to change your code:
$(document).ready(function () {
$('#silmesaji').hide();
$(".delbutton").click(function () {
var element = $(this);
var silinecek_idi = element.attr("id");
var info = 'id=' + silinecek_idi;
$("#silmesaji").dialog('open');
});
$("#silmesaji").dialog({
autoOpen: false;
modal: true,
/* Your code */
});
});
Upvotes: 1