'$ .fn' is null or not an object

Problem 1

Error: Microsoft JScript Runtime Error: "$ .fn" is null or not an object

Error area:

    $.fn.apply=function(item,content,header){

        $(".featureBox"+item).css('z-index', "1000");
        $("img.featureBox" + item +"top").attr("src",basepath + "box-big-top.jpg");
        $("img.featureBox" + item +"imgcut").attr("src",basepath + "box-big-img"+item+".jpg");
        featureboxcont[item].attr("src",basepath + "box-big-cont.jpg");
        $("img.featureBox" + item +"foot").attr("src",basepath + "box-big-bot2.jpg");
        //$("#NoteModalDialog > #x-dlg-bd > #x-dlg-tab > #acc-ct")

        $("#box"+item+"headtext > .h2div > h2").text(header);
        $("#box"+item+"bottext").css({"top":"181px","width":"205px","font-size":"12px","color":"#ffffff","left":"10"});
        $("#box"+item+"foottext").css({"top":footheight+"px","width":"215px","left":"20"});
        $("#box"+item+"hidden").css({"display":"block"});
        $("#box"+item+"bottext").text(content);
        $("#box"+item+"headtext > .h2div > h2").removeClass("sIFR-replaced");
        callsIFR();
    }

      

Problem 2

Error: Microsoft JScript Runtime Error: "null" is null or is not an object

Error area:

$("#innerWrapper").addClass("js-version");

      

I am also using protoype.js on the page.

+2


a source to share


4 answers


If you are using jQuery and Prototype on the page, $.fn

it will most likely be undefined in the global scope. The only way to use jQuery and Prototype on the same page is to use jQuery.noConflict

and assign it a different symbol than $

that Prototype also uses.



+1


a source


It looks like your problem is that both prototype and jQuery are using the function / variable name $

. Check out this page on how to set up jQuery so it doesn't conflict with the prototype.



+2


a source


Why are you filing an expression in the declaration? apply is used to specify this by a method. usually you do something like this ...

var object1 = {X:"stuff"};

var $.fn = function () {
   /* substitute your method here */
   this.X = this.X || "default";
   alert(this.X);
};

$.fn.apply(object1);

      

0


a source


For problem 1, you can resolve conflicts with prototype.js simply by using

jQuery.fn.apply = …

      

Then you avoid conflict between the two libraries.

0


a source







All Articles