Store the id on the dialog using .data():

$('.buttons').click(function() {
    $('#dialog').data('openingElementId', this.id).dialog('open');
    return false;
});

Then later you can do $('#dialog').data('openingElementId') to get
that id back.


On Dec 2, 9:21 am, grunk <[email protected]> wrote:
> Hi,
> I'm a new user of jquery and jqueryui.
> How can i get the id of the element which fired the modal box when i
> click on one of the box's button ?
>
> $("#dialog").dialog({
>                         bgiframe: true,
>                         resizable: false,
>                         height:140,
>                         modal: true,
>                         buttons: {
>                                 'Sure ?': function() {
>                                         // I would like to get the id of the 
> element which open the modal
> box
>                                 },
>                                 Cancel: function() {
>                                         $(this).dialog('close');
>                                 }
>                         }
>                 });
>
> $('.buttons').click(function(e){
>     e.preventDefault();
>     $('#dialog').dialog('open');
>
> });
>
> <img src='img1' id='i1' class=".buttons" alt="test" /> <img src='img1'
> id='i2' class=".buttons" alt="test" /> <img src='img1' id='i3'
> class=".buttons" alt="test" />
>
> When i click on this image i would like to use the id of the element
> in the abstract function wich define the action of the button.
>
> Any idea ?
>
> Thanks

--

You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en.


Reply via email to