views:

24

answers:

2

So I got this code

$(document).ready(function(){
    $.fn.loadView = function(a){
    };

    $('#id').click(function(){
        $.fn.loadView();
    });

    $.fn.loadView();
});

So when the code loads up the initialized $.fn.loadView() just fine the first time. But then when $('#id').click is activated I get this error

$.fn.loadView is not a function

Whats really making me mad is that I just got done doing something exactly like this on another project and it worked just fine.

+1  A: 

Make sure that you're not including jQuery twice in the page, this is the most common cause of plugin functions being undefined later. Since a later include replaces the jQuery/$ object, all methods defined on it are lost.

Nick Craver
LOL i would have never suspected this... least now its out here on the internet. I was searching all over for a possible answer. Thank you :)
Banning
@user293153 - welcome :)
Nick Craver
@nick, you're the man! lol :D
Topera
@nick oh, by the way, have a nice wedding! ;)
Topera
@Topera - thanks :)
Nick Craver
+1  A: 

In this example in jsfiddle, this works. Maybe you're include jquery twice, as @nick said.

Topera