Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#13618 closed feature (plugin)

Feature request: $(window).loaded(function(){...});

Reported by: trusktr Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

$(window).load(function(){...}); works fine for doing things after the window is loaded when the event fires, but unlike $(document).ready(function(){...}); it does not fire if it is executed after the window is loaded. For example, $(document).ready(function(){...}); will execute even after the window is already ready.

Can you make a $(window).loaded(function(){...}); feature that would be have just like $(window).load(function(){...}); but it could be fire any time after the window is loaded?

Change History (2)

comment:1 Changed 7 years ago by dmethvin

Resolution: plugin
Status: newclosed

This isn't a common need. You could do it easily yourself by setting a flag or create a plugin to do it.

comment:2 Changed 7 years ago by jaubourg

For fun and profits (tm):

$.windowLoaded = $.Deferred(function( defer ) {
    $( window ).load( defer.resolve );
}).done;

// Usage
$.windowLoaded(function() {
   // Works before and after the event
});

Untested but should do the work ;)

Note: See TracTickets for help on using tickets.