Reputation: 1258
I use the accordion function in JqueryUI. In each item there is a submit button with the name. The name is the id i need in the dialog window. When i click on the submit button this function is used
$( ".opener" ).click(function() {
console.log( $(this).attr("name"));
$( "#dialog-confirm" ).dialog( "open" );
});
in my console log i see the correct id now. But in the dialog window i can't get get this id. This is the Dialog window
$(function() {
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: {
effect: "fade",
duration: 500
},
hide: {
effect: "fade",
duration: 200
},
resizable: false,
height:180,
modal: true,
buttons: {
"Aannemen": function() {
$( this ).dialog( "close" );
alert('ID IS'); << this is where i want the id
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
So how can i get the id on this position of the script: alert('ID IS');
Upvotes: 0
Views: 91
Reputation: 3281
var name;
$( ".opener" ).click(function() {
name =$(this).attr("name");
$( "#dialog-confirm" ).dialog( "open" );
});
$(function() {
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: {
effect: "fade",
duration: 500
},
hide: {
effect: "fade",
duration: 200
},
resizable: false,
height:180,
modal: true,
buttons: {
"Aannemen": function() {
$( this ).dialog( "close" );
alert(name); << this is where you get the id
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
Upvotes: 1