As you can see on this page http://musicglaze.com/chase-status-let-you-go-feat-mali-feed-me-remix/#comments
comment section is way out of place, After research I understood that it is caused because plugin responsible for styling (http://masonry.desandro.com/) is called within
$(document).ready(function(){
});
function. however, content is loaded into iframe after that, therefore changing its height, but as plugin takes into account its original height without content everything gets messed up. Is there something I can use which would behave similar to this pseudocode?
Document ready AND iframe content loaded {
//My jQuery code
}
The Document Ready Event This is to prevent any jQuery code from running before the document is finished loading (is ready). It is good practice to wait for the document to be fully loaded and ready before working with it.
$( document ).ready()A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute.
jQuery Document Ready Example $(document). ready(function() { //DOM manipulation code }); You call jQuery's $ function, passing to it the document object. The $ function returns an enhanced version of the document object.
Basically, the most reliable way to check if jQuery has been loaded is to check typeof jQuery — it will return "function" if jQuery was already loaded on the page, or "undefined" if jQuery hasn't been loaded yet.
Use $('#iframeId').load(function() { ... });
instead of onReady
. The underlying issue is that there are cross-domain security risks to allowing the parent frame access to an iframe's content, so onReady
is not available, but onLoad
is still accessible. For more details, see: http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/
same ready() function
$(document).ready(function() {
$('#frameId').ready(function() {
...
});
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With