aboutsummaryrefslogtreecommitdiffstats
path: root/src/jqLite.js
diff options
context:
space:
mode:
authorIgor Minar2011-01-09 00:57:24 -0800
committerIgor Minar2011-01-10 10:24:12 -0800
commitc79aba92f6b058742c9ae20a9382f6abc68afcea (patch)
tree4aece29942b7cde621c2a31284e3723314f30d74 /src/jqLite.js
parent84dedb81e79a56b4c81fe413a41e7247d8fa0572 (diff)
downloadangular.js-c79aba92f6b058742c9ae20a9382f6abc68afcea.tar.bz2
bootstrap angular on "document ready" instead of window.onload
- use jqLite api to bootstrap angular - when jQuery is present DOMContentLoaded or hacks for IE are used - when jqLite is present DOMContentLoaded is used for modern browsers and IE9 and window.onload is used for other browsers. - test html for comparing DOMContentLoaded with window.onload Closes #224
Diffstat (limited to 'src/jqLite.js')
-rw-r--r--src/jqLite.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/jqLite.js b/src/jqLite.js
index cbba69ad..cbb2c7b8 100644
--- a/src/jqLite.js
+++ b/src/jqLite.js
@@ -87,6 +87,19 @@ JQLite.prototype = {
})(this[0]);
},
+ ready: function(fn) {
+ var fired = false;
+
+ function trigger() {
+ if (fired) return;
+ fired = true;
+ fn();
+ }
+
+ this.bind('DOMContentLoaded', trigger); // works for modern browsers and IE9
+ jqLite(window).bind('load', trigger); // fallback to window.onload for others
+ },
+
bind: function(type, fn){
var self = this,
element = self[0],