I have a page within an iframe with a button that when clicked opens a modal. What I want is for the backdrop and modal content to open up in the parent window, not within the iframe.
To test this out I've made some mods to the javascript so that instead of appending the backdrop to document.body, I append it to window.parent.document.body. I made the same change to $element in the show method. The backdrop successfully was added to the parent window but I couldn't get the modal content to do the same.
Any tips on how to do this cleanly?
Since the iframes must be on the same domain, my suggestion would be to have the modal content in the parent, and when something is clicked in the child, explicitly trigger "click" on a hidden opener in the parent. ie, do all the modal work in the parent, not in the child.
+1 @ljharb
Have the modal live in the parent, then call window.parent.$("#modal").modal()
Could you please ask questions like this in the mailing list? thanks! :)
quasipickle , your solution solve my problem. Thx!
Thanks ljharb and quasipickle. This solved the problem for me too. Now, I need to know how to avoid the iframe page jumping on the top when the modal popup opens...
thank you so much
How is this implemented?
Most helpful comment
+1 @ljharb
Have the modal live in the parent, then call
window.parent.$("#modal").modal()