Accessing dynamically generated dialog using JQuery
Hello Everyone thanks in advance.
I am initiazializing a dialog on the fly using the following code:
- $("<div id='timeOffDiv'><div id='timeOffDivInner'>loading....</div></div>").dialog({...options go here....});
I use this often in my app and it works well..usually on open, I populate the content of the dialog dynamically using ajax.
later, based on user controls, I need to change the dialog buttons, and I use the following code:
- $('div#timeOffDiv').dialog('option','buttons', [
- {
- text: 'SUBMIT REQUEST',
- click: function () {
- $("form#addTimeOffForm").submit();
- }
- },
- {
- text: 'CANCEL',
- click: function() {
- $(this).dialog("close");
- $( this ).dialog("destroy").remove();
-
- }
- }
- ]
- );
This techinically works, but I am getting an error, although not fatal, that says the following:
jquery.js:2 Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'option'
Any thoughts on getting this error to go away?? I am pretty sure this has to do with the first dialog not being recognized as the same one being referenced later, athough the code still works.