2

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.

5
  • Where is the element with class = myLink ?? Commented Apr 21, 2011 at 20:13
  • Good catch, sorry I forgot to put class in links. Commented Apr 21, 2011 at 20:37
  • I updated my question. I know how to get the value from link and need to pass it to a script via ajax to do some db manipulation. Commented Apr 21, 2011 at 20:38
  • This is correct. so what do you want now ? Commented Apr 21, 2011 at 20:44
  • Does my AJAX look right? It does not seem to be working... Commented Apr 21, 2011 at 20:48

2 Answers 2

2

I think you just need to change

data: "delete=delID",to <br />
data: "delete="+delID,
Sign up to request clarification or add additional context in comments.

Comments

1

try changing the line

$(".myLink").click(function(){
to
$(".myLink").live("click", function() {
however there is a bug in the lines when I test it. To get the dialog you should move the lines
    var delURL = $(this).attr("href").split("#");
    var delID  = delURL[1]; 

above

    $dialog.dialog("open");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.