Get the id of the link and pass it to the jQueryUI dialog widget

Posted by Mike Sanchez on Stack Overflow See other posts from Stack Overflow or by Mike Sanchez
Published on 2012-09-03T15:13:40Z Indexed on 2012/09/03 15:38 UTC
Read the original article Hit count: 225

I'm using the dialog widget of jQueryUI. Now, the links are grabbed from an SQL database by using jQuery+AJAX which is the reason why I used "live"

$(function() {
    var $dialog = $('#report')
            .dialog({
                autoOpen: false,
                resizable: false,
                modal: true,
                height: 410,
                width: 350,
                draggable: true
            })
        //store reference to placeholders
        $uid = $('#reportUniqueId');

    $('.reportopen').live("click", function (e) {
        $dialog.dialog('open');
        var $uid = $(this).attr('id');
        e.preventDefault();
    });
});

My question is, how do I pass the id of the link that triggered the dialog widget to the dialog box itself? The link is set up like this:

<td align="left" width="12%">
  <span id="notes">
    [<a href="javascript:void(0)" class="reportopen" id="<?=$reportId;?>">Spam</a>]
  </span>
</td>

And the dialogbox is set up like this:

<div id="report" title="Inquire now">
HAHAHAHAHA
<span id="reportUniqueId"></span>
</div>

I'd like for the id to be passed and generated in the <span id="reportUniqueId"></span> part of the dialog box.

Any idea?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui