Is there any convention for functions written in jQuery that are to be called from a child document (i.e. inside an <iframe>
) to the parent document?
Following on from my question yesterday, regarding the use of an iFrame
in a jQuery UI .dialog
... I need the page inside the iframe
to alter the size of the dialog at a particular time.
I already have this working, with the following code in the child document...
window.parent.$("#myDiv").dialog("option", "height", 180).dialog("option", "width", 300);
However, I think it would be cleaner and easier to understand if the code (which is much more complex than just that line) was included with the original .dialog
code in the parent document.
This could obviously be done simply having the following in the parent document...
function resizeDialog() {
$("#myDiv").dialog("option", "height", 180).dialog("option", "width", 300);
}
... and the following in the child document
window.parent.resizeDialog();
However, I want to know if there is any convention for including the resizeDialog function as part of the $("#myDiv")
so that it be called with something like...
$window.parent.$("#myDiv").resize();
Update
I guess the question I'm trying to ask is this:
Is it considered unacceptable to have a function like this when using jQuery...
function resizeDialog() {
$("#myDiv").dialog("option", "height", 180).dialog("option", "width", 300);
}
If so, then what is the format for having a jQuery function that can be called from outside of the current document?