Skip to content Skip to sidebar Skip to footer

Jquery Plugins Triggerable By Console, But Not By Function - Why That?

I have a mysterious JS Problem: I activate different jQuery-Plugins with one function. It's called like this: Then, the correspondi

Solution 1:

Try your code within $(document).ready(function() { .. }) in short $(function() { .. }) to execute your code after DOM ready.

jQuery(document).ready(function() {

  function postAjaxCalls() {
    jQuery("[title]").tooltip(); 
    alert("this works great, tooltip not!");
    jQuery("select").selectbox();
  } 
  postAjaxCalls();

});

OR in short

jQuery(function() {

  function postAjaxCalls() {
    jQuery("[title]").tooltip(); 
    alert("this works great, tooltip not!");
    jQuery("select").selectbox();
  } 
  postAjaxCalls();

});

Solution 2:

You are probably calling postAjaxCalls before the DOM is ready. When you call it from the console, the DOM is ready, so it works.

Try this:

$(function(){
    postAjaxCalls();
});

Post a Comment for "Jquery Plugins Triggerable By Console, But Not By Function - Why That?"