Reputation: 12512
I have a number of items on a page that when clicked trigger UI's modal dialog.
var $dialog = $("#dialog").dialog({
autoOpen: false,
resizable: false,
modal: true
});
$(".myLink").click(function(){
$dialog.dialog("open");
$("#dialog").dialog({
var delURL = $(this).attr("href").split("#");
var delID = delURL[1];
buttons: {
"Delete": function() {
// need to add AJAX call here
$.ajax({
type: "POST",
url: "some.php",
data: "delete=delID",
success: function(msg){
alert( "Deleted: " + msg );
}
});
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
I need to pass anchor value to another page when "Delete" button is clicked. I thini I need to use AJAX.
<a href="#val_1" class="myLink">Value 1</a>
<a href="#val_2" class="myLink">Value 2</a>
<a href="#val_3" class="myLink">Value 3</a>
Not sure how to do it.
Upvotes: 2
Views: 1629
Reputation: 1810
I think you just need to change
data: "delete=delID",to <br />
data: "delete="+delID,
Upvotes: 2
Reputation: 1105
try changing the line
to
$(".myLink").click(function(){
however there is a bug in the lines when I test it. To get the dialog you should move the lines
$(".myLink").live("click", function() {
var delURL = $(this).attr("href").split("#");
var delID = delURL[1];
above
$dialog.dialog("open");
Upvotes: 1