Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Plugin pluginname(); is not a function

Tags:

jquery

plugins

I have a plugin that works fine on one site but on http://www.inhouse-advertising.com I get the following error in firebug: $("body").facebookTrafficPop is not a function

I have tried with just jQuery and just $.fn.FBTP() but still a no go and I know the order is correct. jQuery is being loaded before the plugin.

Help!

like image 933
Tyler Avatar asked May 03 '11 18:05

Tyler


2 Answers

There are a few possibilities:

  1. There may be some other script it's depending on that aren't being loaded, or loaded in time.
  2. The plugin method is potentially being called before the code for the plugin is loaded.
  3. There is a script error prior to plugin call that is cascading and that's just where it's being caught.

It's difficult to diagnose without a link, however. Is this up anywhere where we can see it?

like image 86
jszpila Avatar answered Oct 23 '22 02:10

jszpila


It looks like the $(document).ready call is getting called before everything loads. You could try to put it an a different method and do something like this:

At the end of your html (very last line) do this call:

<script type="text/javascript">webpageReady();</script>

Then change the function from $(document).ready to webpageReady(). This will ensure that everything is loaded before the $('body').facebookTrafficPop call is done.

Also make sure the script is visible in head

like image 27
Soatl Avatar answered Oct 23 '22 02:10

Soatl