Tutorial :Problem to have access to jquery plugin inside $(document).ready() with django-debug-toolbar


I wrote my own jquery plugin and was amazing that I haven't access to it inside $(document).ready function.

I write this testpage and was amazing more:

    /**       * jQuery anchor plugin       */      (function($) {          $.anchor = {              hashTrim: /^.*#/,          }      })(jQuery);        console.log($.ajax);      console.log($.anchor);        $(function() {          console.log($.ajax);          console.log($.anchor);      });  

I'v got 4 complettely different values in firebug console. Do somebody know and can describe me wy it is? And main question - how I can have access to my $.anchor variable inside $(function() {} ???

Thу testcase is here http://movister.ru:5190/html/test.html



I just catch the problem - django-debug-toolbar. When I disabled it, everythings becomes ok!

Does anyone know how to make friendship between jquery and django-debug-toolbar?




Just tested your code sample, and both times the result is identical. But in general and for the future extend $.fn due to the fact it extends the jQuery object prototype. When you do just $.anchor you are just extending that instance of the object.


I think that should be:

(function($) {      $.fn.anchor = {          hashTrim: /^.*#/,      }  })(jQuery);  


I get the same result both times too, same as the other guys.


I partially solve this problem by switching to the another fork - alex's django_debug_toolbar.

But I think it's more ugly, then david cramer's django_debug_toolbar, that I use before and which contains this problem with jQuery. I hope to move functionality for avoiding this problem from alex's to dcramer's fork in future.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »