views:

70

answers:

2

In the example below, how can you use the event and ui objects to detect which link opened the dialog? Can't seem to get $(event.target).attr("title"); to work properly, and I'm having trouble finding documentation on the 'ui object that is passed. Thanks!

$("#dialog_support_option_form").dialog({
   link_title = $(event.target).attr("title");
   alert(link_title);
});


$("a").live("click", function() {
    btn_rel = $(this).attr("rel");
    $(btn_rel).dialog("open");
});

<a class="btn pencil" rel="#dialog_support_option_form" title="Edit Support Option">Edit</button>
A: 

parents() returns multiple records use parent() instead.

Ivo Sabev
I just simplified the code in my post to just try to get the title of the button, just ran a test and I can't even get the title of the button...
Dan
A: 

You need to do that detection in the click event that opens it, you can then use it and set something in the dialog, alert it...whatever you're looking to do with the value, like this:

$("a").live("click", function() {
  var btn_rel = $(this).attr("rel");
  $(btn_rel).dialog("open");
  var title = $(this).attr("title");
  //alert(title);
  //or:
  //$("#dialog_support_option_form .something").text(title);
  //whatever you want to do with it :)
});
Nick Craver
Gosh, I just thought JQuery would have a prettier way of passing the variable. Guess this will have to do. Thanks for the help!
Dan