Skip to content

Instantly share code, notes, and snippets.

@sampsonbryce
Created January 26, 2017 20:05
Show Gist options
  • Save sampsonbryce/90620550d322a08bdc1c615f8dad2a7b to your computer and use it in GitHub Desktop.
Save sampsonbryce/90620550d322a08bdc1c615f8dad2a7b to your computer and use it in GitHub Desktop.
waitUntilExists
(function(e,f){var b={},g=function(a){b[a]&&(f.clearInterval(b[a]),b[a]=null)};e.fn.waitUntilExists=function(a,h,j){var c=this.selector,d=e(c),k=d.not(function(){return e(this).data("waitUntilExists.found")});"remove"===a?g(c):(k.each(a).data("waitUntilExists.found",!0),h&&d.length?g(c):j||(b[c]=f.setInterval(function(){d.waitUntilExists(a,h,!0)},500)));return d}})(jQuery,window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment