I'm trying to make a div from inside of the dialog be the 'close' button of the dialog box, but after passing an event onto it, I get this error: cannot call methods on dialog prior to initialization; attempted to call method 'close'
I've tried intializing it in a variable (with var $this = $(this);) but nothing seems to be getting rid of that error.
My HTML & PHP:
<?php
print(
"<div id='dialogBox' class='dialogBox shadow ui-draggable ui-resizable' style='display: block; top:20px;'>".
"<div id='boxHeader'>".
"<div id='boxHeaderText'>"._BEANDF_LOG_SELECT. "</div>".
"<div id='closeBox'>". _BEANDF_CONTROL_CENTER_CLOSE. "</div>".
"<div style='clear:both'>".
"</div>".
"</div>".
);
?>
The jQuery:
function initImpactFactorDialog(){
$("#opener").click(function() {
($("#dialogBox").dialog("isOpen") == false) ? $("#dialogBox").dialog("open") : $("#dialogBox").dialog("close") ;
});
$("#dialogBox").dialog({
autoOpen: false,
draggable: true,
width: 700,
height: 300,
position:[440,118],
//buttons
close:
$("#closeBox").click(function() {
$(this).dialog('close');
})
});
}
The dialog box should close when clicking on my custom button. Thank you!