document-ready

Why does $(window).load() work but not $(document).ready()?

末鹿安然 提交于 2019-12-04 08:09:55
I'm working with a rails 3 app, and I want to use a sortable list. I'm working with the method shown here . My app uses JQuery, and there's a js file included in my app's layout that calls $(document).ready() to set up some visual stuff. That seems to be working fine. However, when I attempt to call $(document).ready() in my view template via content_for :javascript to set up the sortable list, that code never fires. I do have the requisite yield :javascript call in my layout file, and if I load the page and look at the source everything looks fine. The code never runs, though – i.e. this

managing document.ready event(s) on a large-scale website

空扰寡人 提交于 2019-12-04 07:39:38
问题 NOTE: I have now created a jQuery plugin which is my attempt of a solution to this issue. I am sure that it could be improved and i've probably overlooked lots of use cases, so if anyone wants to give feedback feel free :-) https://github.com/WickyNilliams/ReadyBinder I don't have a problem as such, but thought this would be an interesting point for discussion, and i hope people have some interesting ideas for this. Basically, i work on a large-scale website and increasingly we are writing

jQuery $(document).ready broken in Iron/Chrome

一个人想着一个人 提交于 2019-12-04 06:29:52
I've written a little image slideshow using jQuery and jFancyTiles which can be seen here: http://www.netzwerkag.at It works as expected in firefox and IE, but not in iron/chrome.The problem seems to be in the timing of document.ready in chromium: In line 76 the active class is set to the numbered circle-buttons in the lower right corner of the header image. This works! In line 83 the image is changed by calling the fancy-tile-function, this doesn't work in chromium, at least not at this time. When i open the iron_js_console via ctrl-shift-j and manually call the function everything works.

Passing parameters into a closure for setTimeout

删除回忆录丶 提交于 2019-12-04 03:28:31
问题 I've run into an issue where my app lives in an iframe and it's being called from an external domain. IE9 won't fire the load event when the iframe loads properly so I think I'm stuck using setTimeout to poll the page. Anyway, I want to see what duration is generally needed for my setTimeout to complete, so I wanted to be able to log the delay the setTimeout fires from my callback, but I'm not sure how to pass that context into it so I can log it. App.readyIE9 = function() { var timings = [1

Difference between $(document).ready and $(document).on('pageinit')

心不动则不痛 提交于 2019-12-04 02:49:49
I'm using jquery mobile and I'd like to reproduce this code: $(document).ready(function () { $.mobile.loading('show'); }); it shows the spinner until I decide to hide it using in other functions $.mobile.loading( 'hide' ); Now I see that document.ready() is deprecated in jquery mobile 1.2, so they suggest to replace it with $(document).on('pageinit') But If I replace my code with the suggested one the spinner autohide... why? This is the new code: $(document).on('pageinit',function(){ $.mobile.loading( 'show' ); }); Gajotres Related: This article can also be found as a part of my blog HERE .

What are the side effects (if any) of multiple $(document).ready() in an HTML page?

痞子三分冷 提交于 2019-12-04 02:31:14
I am using a web application framework (Symfony 1.3.6), which follows the MVC pattern. The view layer is comprised of a template decorator. The template file may also include other templates - this is what gives rise to my question. Assuming that there is a page (lets call it the 'homepage'), which is comprised of several templates - (the code has been refactored out so the 'sub templates' can be used on other pages. As a result of the refactoring, the small templates - which are used by the main template - ('homepage' in our example), need to contain their jQuery related code. lets say the

jquery loaded async and ready function not working

↘锁芯ラ 提交于 2019-12-04 01:54:49
问题 In order to optimize the load of my document, I use to load jquery async like that <script async type="text/javascript" src="js/jquery-1.12.3.min.js"></script> Then I call a script using jquery : <script type="text/javascript"> jQuery(document).ready(function() { App.init(); OwlCarousel.initOwlCarousel(); FancyBox.initFancybox(); StyleSwitcher.initStyleSwitcher(); }); </script> It returns me that jquery is not defined. I don't know what should I use, I though that .readyfunction would wait

Why does window.onload event occur before $(document).ready?

我怕爱的太早我们不能终老 提交于 2019-12-04 01:39:55
As stated in this thread: window.onload vs $(document).ready() . The window.onload should occur later than the $(document).ready() but in this simple code the log would show that the onload event is executed before the ready event? What I'm I missing here? <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> </head> <body> <h1>A Simple Site</h1> <script> $(document).ready(function() { console.log("ready event fired"); }) window.onload = function() { console.log("onload event fired"); } </script> </body> </html> The problem is

Running a function just before $(document).ready() triggers

萝らか妹 提交于 2019-12-04 01:23:17
I've attached multiple functions in multiple files to $(document).ready and would like to attach a single function to happen before them as either the first that $(document).ready handles or to independently trigger before the $(document).ready handler. Is there any way to handle the order of functions that jQuery triggers internally as part of jQuery.fn.ready or to hook in a function that calls just before jQuery.fn.ready. Is editing jQuery.fn.ready in a 3rd party script safe to do or will it cause horrible knock on effects in other 3rd party plugins (apart from plugins that edit jQuery.fn

browserify and document ready?

泪湿孤枕 提交于 2019-12-03 16:50:04
问题 I'm struggling with using Browserify and document ready events. How do I craft a module that exports content only available after the document ready event has fired? How do I depend on such a module? My first stab was to try to set module.exports asynchronously -- fail out of the box. My nextx stab at this was for the module to return a function that took in a callback, and called the callback when document ready fired. Third attempt returned a promise. This seems to make dependent modules