Reputation: 509
I have the following jquery code
function deleteAppointment(confirmationNumber)
{
// alert(confirmationNumber);
$('#left').simpledialog({
'mode' : 'bool',
'prompt' : 'Confirm Delete',
'useModal': true,
'buttons' : {
'OK': {
click:function () {
// alert(confirmationNumber);
var link;
link = ROOT_URL+'Queue/cancelreservation/confirmnumber/'+confirmationNumber;
$.ajax({
url: link,
type: 'GET',
async: true,
success: function(data){
renderAgain();
addRightPane();
$(APPOINTMENT_LIST_CLASS).animate({
scrollTop: 0
});
},
error: function(){
/*@TODO : What if the ajax request fails */
}
});
}
},
'Cancel': {
click: function () {
$('#dialogoutput').text('Cancel');
},
icon: "delete",
theme: "c"
}
}
});
}
the problem is that confirmation number I pass to the delete appointment function is only passed for the first time and is not updated the next time. It holds the value of old confirmation number so I figured out that I have to pass the confirmation number to the click function. Can any one help me on how to do that ? or what I am missing here ?
Upvotes: 0
Views: 1644
Reputation: 76
After few weeks more experience in jquerymobile I find more elegant and right way to fix this issue
just use a property of simple dialog
'cleanOnClose' : true
this will fix your problem
Upvotes: 2
Reputation: 1
Wanted to do same thing like you have done, one function that will refill a simple dialog but the problem is that onclick has to be unbind and bind again but I didn't know how.I just make a work around and used a global variable to pass a paramater
this should do a trick... if somebody knows how to rebind events please let us know
var selected;
function deleteAppointment(confirmationNumber)
{
selected = confirmationNumber;
// alert(confirmationNumber);
$('#left').simpledialog({
'mode' : 'bool',
'prompt' : 'Confirm Delete',
'useModal': true,
'buttons' : {
'OK': {
click:function () {
// alert(selected );
var link;
link = ROOT_URL+'Queue/cancelreservation/confirmnumber/'+selected ;
$.ajax({
url: link,
type: 'GET',
async: true,
success: function(data){
renderAgain();
addRightPane();
$(APPOINTMENT_LIST_CLASS).animate({
scrollTop: 0
});
},
error: function(){
/*@TODO : What if the ajax request fails */
}
});
}
},
'Cancel': {
click: function () {
$('#dialogoutput').text('Cancel');
},
icon: "delete",
theme: "c"
}
}
});
}
Upvotes: 0
Reputation: 7954
I believe that your delete button is something like this
<a class="deleteappoinment" href="javascript:void(0);" id="12">Delete</a> //here 12 is an example of conformation id, change it accordingly
$(document).ready(function(){
$('.deleteappoinment').click(function(){
deleteAppointment($(this).attr('id'));
});
});
function deleteAppointment(confirmationNumber){
//code
}
Upvotes: 0