views:

209

answers:

3

I'm not entirely sure what's happening here. I have my code that exists like:

var mycode = {
    init:function(){
        //my code here
    }
}

//sizzle pasted here...
(function(){ //sizzle code here })();

Where "sizzle code here" is the copy/paste of Sizzle in its entirety. Sizzle is contained in an anonymous function, so I'm not sure what the interference is.

As soon as I add Sizzle in this manner, my js in the "mycode" object literal stops working and I get errors like "mycode is not defined". This happens in Chrome on Mac, Firefox 3.5.x, and Safari 4 Mac.

A: 

Missing the closing paren for your function wrapper, should be:

(function(){ //sizzle code here })();
jjacka
Thanks. That was an error in my question, unfortunately not the actual code.
Geuis
+1  A: 

the code should be

   var mycode = {
        init:function(){
            //my code here
        }
   };

    //sizzle pasted here...
   (function(){ //sizzle code here })();

the missing semicolon after your 'mycode' object results as,

var mycode = { init:function() {}}(function(){/*sizzle code here*/ })();

which results in error ;)

Livingston Samuel