The following codes won't work. If you call rPrompt twice with
different index value, the second index value won't be passed to the
"close" event handler. I can work around this issue by using a global
var like gIndex to store the index value, but I would like to know if
there is a more elegent solution. Thanks.
function rPrompt(index, msg)
{
alert(index);
if($("#prompt").length == 0){
$("<div id='prompt'><label></label><textarea rows='5'
cols='30'></
textarea></div>").appendTo("body");
$("#prompt").dialog({
title: "Test",
modal: true,
bgiframe: true,
overlay: {
backgroundColor: '#000',
opacity: 0.3
},
buttons: {
'Cancel': function(){
$(this).dialog("close");
},
'OK': function(){
$(this).dialog("close");
}
},
close: function(){
alert(index);
}
});
}else{
$("#prompt").dialog("open");
}
$("#prompt label").html(msg);
}