Josh Knutson

Pondering Life Away

Check if jQuery is found on page

 
 

I was adding a feature to my debug and wanted to make it so I could init my application with a button click instead of opening up a new tab or initiating the current page.So to make sure my code would work anywhere and not throw an error I now put in the check to see if jQuery is found.

if (typeof jQuery == 'function') {
   jQuery('#reloadJax').live('click', function(event){
      var loadingText = '<span class="CFDdebugLoader">Loading..</span>';
      jQuery('#reloadJax').html(loadingText);
      $.get("#currentaddress#", function(data){
         jQuery('#reloadJax').text('AJAX Reinitialize');
      });
      event.preventDefault();
   });
   function addReload(){
      var vhtml = '<a id="reloadJax" class="CFDdebugButton ui-state-default ui-corner-all" title="AJAX Reinitialize" href="#currentaddress#">AJAX Reinitialize</a>';
      jQuery('#jaxReload').html(vhtml)
   };
   addLoadEvent(addReload);
}

1 response to “Check if jQuery is found on page”

  1. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

    test

    test ~ Jan 17, 2010 at 7:47 PM

Leave this field empty: