[jQuery] jquery ui dialog get element from button
Hi,
I have probably a simple question which i cannot seem to find the
answer to.
I have a series of images which i want to use as buttons to trigger a
dialog. Inside this dialog i need the ID of the image button (or any
other element). But it seems after I load the dialog i cannot alter
the content of it anymore. As an example I have tried to change the
title of the #dialog so it will show the updated title when i click
the button. The only way i am able to do this is when i put all of
this inside the .click function and start with .attr function followed
by the .dialog function. The problem is when i do this and close the
dialog i cannot enable the dialog anymore. I guess this is why they
have the .dialog("open").
Is there a way i can achieve what I'm trying to do here? Maybe there
is a better way of doing this?
Tia,
Carlo
code:
$(document).ready(function(){
$(".button").click(function(event){
$("#dialog").attr("title", event.target.id);
$("#dialog").dialog({
autoOpen:true,
modal:true,
overlay: {backgroundColor: "#000",opacity: 0.5},
resizable:false,
buttons:{
"Delete": function() {},
"Cancel": function() {$(this).dialog("close");}
}
});
});
});
<div id="dialog" title="i did not change">this is a test</div>