Permalink
Browse files

Use jQuery's version of onDOMReady instead of just firing initialisat…

…ion JS immediately.
  • Loading branch information...
1 parent 2595c61 commit c55d00cdd97792dcb4cbbb7675f48a8cca29e7b9 @beastaugh committed Jun 25, 2011
Showing with 13 additions and 8 deletions.
  1. +8 −3 library/helpers/template_helper.php
  2. +5 −5 searchform.php
@@ -348,9 +348,14 @@ function navbar_wrapper() {
echo <<<NAVBAR_SCRIPT
<script type="text/javascript">
- (function() {
- var navbar = new Tarski.Navbar(jQuery('#navigation'));
- })();
+ jQuery(document).ready(function() {
+ var container = document.getElementById('navigation'),
+ navbar;
+
+ if (container) {
+ navbar = new Tarski.Navbar(container);
+ }
+ });
</script>
NAVBAR_SCRIPT;
}
View
@@ -8,13 +8,13 @@
</div>
<script type="text/javascript">
- (function() {
- var searchField = jQuery('#s'),
- searchLabel = jQuery('#searchlabel'),
+ jQuery(document).ready(function() {
+ var searchField = document.getElementById('s'),
+ searchLabel = document.getElementById('searchlabel'),
searchBox;
- if (searchField.length > 0 && searchLabel.length > 0) {
+ if (searchField && searchLabel) {
searchBox = new Tarski.Searchbox(searchField, searchLabel);
}
- })();
+ });
</script>

0 comments on commit c55d00c

Please sign in to comment.