Created
February 19, 2011 06:01
-
-
Save thiamteck/834867 to your computer and use it in GitHub Desktop.
JQuery, slicing long running script into batches to eliminate IE's "Stop running this script?" warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
// original line that might trigger IE warning | |
// $(":button").button(); | |
var $allButtons = $(":button"); | |
var buttonCount = $allButtons.size(); | |
var buttonized; | |
for(var i = 0; i < buttonCount; i = i + 100){ | |
buttonized = applyButtons($allButtons, i, 100); | |
setTimeout(buttonized, 10); | |
} | |
}); | |
function applyButtons(allButtons, i, batchSize){ | |
return (function(){ | |
allButtons.slice(i ,(i + batchSize)).button(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment