I have the following code, which I am following from the jQuery documentation on how to build a plugin.
I’m just trying to create a simple isNot extension:
(function ($) {
$.fn.isNot = function (selector) {
return !this.is(selector);
};
})(jQuery);
$(document).ready(function () {
$("#someButton").click(function (event) {
alert($("#someCheckbox").isNot(":checked"));
});
});
When I run this the javascript file get’s loaded properly, and I can step through the code in firebug. I see that jQuery is defined properly, and the click event gets wired up properly, too.
However, I have added a watch in FireBug to track the isNot function, and it is always null. I can’t get it to ever become defined.
Is there something I’m not doing properly?
Perhaps the way you are including
jQueryand your plugin is not right.scripttags order.jQueryis loading properlyjQuery, which would make your plugin available in the instance that is not accessible anymore.Here is an working example.
And as you mentioned the problem was really an issue with multiple references to jQuery.
Be careful when using Telerik’s external templates, some files contains controls that loads
JSand/orCSSwhich may conflict with your own.