Reputation: 7092
I am using jQuery-UI dialog boxes and I have a rather complicated situation.
I have attached a function call to the "Save" button for my dialog, but I need to pass in dynamic parameters to that function.
The parameters I need to pass in are an "id" of a textbox element and two variables: "copyNum" which is just an integer and "original" which is 0 or 1. These values are all in the div that the dialog box opens.
So a complete call might look like this:
AddYourAuthors(39842871, 5, 0);
I figured out how to call the function without parameters as shown below.
But I can't figure out how to get the 3 parameters in there because they will all be dynamic.
Any insight would be appreciated.
Thanks!
$("#AuthorByBox").dialog({
autoOpen: false,
modal: true,
buttons: [
{
id: "SaveAuthors",
text: "Save",
click: function () {
//how do I pass parameters to this function call dynamically?
AddYourAuthors();
}]
});
Upvotes: 0
Views: 208
Reputation: 14250
If I understand you correctly... use find
to get the divs.
click: function() {
var dlg = $("#AuthorByBox");
var id = dlg.find("#id").text();
var copyNum = dlg.find("#copyNum").text();
var orig = dlg.find("#original").text();
AddYourAuthors(id, copyNum, orig);
}
Upvotes: 1