directory-backbone-browserify icon indicating copy to clipboard operation
directory-backbone-browserify copied to clipboard

errors

Open jswhisperer opened this issue 11 years ago • 4 comments

error "slider = new PageSlider($('body'))," is not a function tried commenting out but got more similar errors... Has anyone ever tested this app?

jswhisperer avatar Jan 26 '14 18:01 jswhisperer

@gregbenner :+1:

I had a similar problem in both Firefox and Chrome. After following the instructions exactly (no errors or warnings), I opened index.html and the following message shows up in the console:

[08:47:11.075] TypeError: $ is not a function @ file:[...]/directory-backbone-browserify/bundle.js:12589

It seems that the problem is with $ -- perhaps jQuery isn't getting set up properly?

Maybe we're using the wrong version of jQuery, but there's no version specified in package.json so it's impossible to tell.

mattfenwick avatar Jan 29 '14 13:01 mattfenwick

Okay, so there is a jQuery version difference between what @ccoenraets has deployed and what you get if you follow the steps today.

Unfortunately, I don't know if this difference is the cause of the issues we're having, but here's the diff:

diff --git a/jquery-2.1.0-beta3/dist/jquery.js b/jquery-2.1.0/dist/jquery.js
index e6cf8c6..f7f4227 100644
--- a/jquery-2.1.0-beta3/dist/jquery.js
+++ b/jquery-2.1.0/dist/jquery.js
@@ -1,15 +1,15 @@
 /*!
- * jQuery JavaScript Library v2.1.0-beta3
+ * jQuery JavaScript Library v2.1.0
  * http://jquery.com/
  *
  * Includes Sizzle.js
  * http://sizzlejs.com/
  *
- * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
+ * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
  * Released under the MIT license
  * http://jquery.org/license
  *
- * Date: 2013-12-20T22:31Z
+ * Date: 2014-01-23T21:10Z
  */

 (function( global, factory ) {
@@ -23,7 +23,7 @@
        // e.g. var jQuery = require("jquery")(window);
        // See ticket #14549 for more info
        module.exports = global.document ?
-           factory( global ) :
+           factory( global, true ) :
            function( w ) {
                if ( !w.document ) {
                    throw new Error( "jQuery requires a window with a document" );
@@ -34,8 +34,8 @@
        factory( global );
    }

-// Pass this, window may not be defined yet
-}(this, function( window ) {
+// Pass this if window is not defined yet
+}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {

 // Can't do this because several apps including ASP.NET trace
 // the stack via arguments.caller.callee and Firefox dies if
@@ -69,7 +69,7 @@ var
    // Use the correct document accordingly with window argument (sandbox)
    document = window.document,

-   version = "2.1.0-beta3",
+   version = "2.1.0",

    // Define a local copy of jQuery
    jQuery = function( selector, context ) {
@@ -551,20 +551,19 @@ function isArraylike( obj ) {
 }
 var Sizzle =
 /*!
- * Sizzle CSS Selector Engine v1.10.15
+ * Sizzle CSS Selector Engine v1.10.16
  * http://sizzlejs.com/
  *
  * Copyright 2013 jQuery Foundation, Inc. and other contributors
  * Released under the MIT license
  * http://jquery.org/license
  *
- * Date: 2013-12-20
+ * Date: 2014-01-13
  */
 (function( window ) {

 var i,
    support,
-   cachedruns,
    Expr,
    getText,
    isXML,
@@ -2073,8 +2072,8 @@ function addCombinator( matcher, combinator, base ) {

        // Check against all ancestor/preceding elements
        function( elem, context, xml ) {
-           var data, cache, outerCache,
-               dirkey = dirruns + " " + doneName;
+           var oldCache, outerCache,
+               newCache = [ dirruns, doneName ];

            // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
            if ( xml ) {
@@ -2089,14 +2088,17 @@ function addCombinator( matcher, combinator, base ) {
                while ( (elem = elem[ dir ]) ) {
                    if ( elem.nodeType === 1 || checkNonElements ) {
                        outerCache = elem[ expando ] || (elem[ expando ] = {});
-                       if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
-                           if ( (data = cache[1]) === true || data === cachedruns ) {
-                               return data === true;
-                           }
+                       if ( (oldCache = outerCache[ dir ]) &&
+                           oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
+
+                           // Assign to newCache so results back-propagate to previous elements
+                           return (newCache[ 2 ] = oldCache[ 2 ]);
                        } else {
-                           cache = outerCache[ dir ] = [ dirkey ];
-                           cache[1] = matcher( elem, context, xml ) || cachedruns;
-                           if ( cache[1] === true ) {
+                           // Reuse newcache so results back-propagate to previous elements
+                           outerCache[ dir ] = newCache;
+
+                           // A match means we're done; a fail means we have to keep checking
+                           if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
                                return true;
                            }
                        }
@@ -2290,9 +2292,7 @@ function matcherFromTokens( tokens ) {
 }

 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
-   // A counter to specify which element is currently being matched
-   var matcherCachedRuns = 0,
-       bySet = setMatchers.length > 0,
+   var bySet = setMatchers.length > 0,
        byElement = elementMatchers.length > 0,
        superMatcher = function( seed, context, xml, results, outermost ) {
            var elem, j, matcher,
@@ -2309,7 +2309,6 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {

            if ( outermost ) {
                outermostContext = context !== document && context;
-               cachedruns = matcherCachedRuns;
            }

            // Add elements passing elementMatchers directly to results
@@ -2327,7 +2326,6 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
                    }
                    if ( outermost ) {
                        dirruns = dirrunsUnique;
-                       cachedruns = ++matcherCachedRuns;
                    }
                }

@@ -2625,14 +2623,14 @@ jQuery.filter = function( expr, elems, not ) {

 jQuery.fn.extend({
    find: function( selector ) {
-       var i = 0,
+       var i,
            len = this.length,
            ret = [],
            self = this;

        if ( typeof selector !== "string" ) {
            return this.pushStack( jQuery( selector ).filter(function() {
-               for ( ; i < len; i++ ) {
+               for ( i = 0; i < len; i++ ) {
                    if ( jQuery.contains( self[ i ], this ) ) {
                        return true;
                    }
@@ -2640,8 +2638,7 @@ jQuery.fn.extend({
            }) );
        }

-       i = 0;
-       for ( ; i < len; i++ ) {
+       for ( i = 0; i < len; i++ ) {
            jQuery.find( selector, self[ i ], ret );
        }

@@ -2892,12 +2889,11 @@ jQuery.fn.extend({
    },

    add: function( selector, context ) {
-       var set = typeof selector === "string" ?
-               jQuery( selector, context ) :
-               jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
-           all = jQuery.merge( this.get(), set );
-
-       return this.pushStack( jQuery.unique(all) );
+       return this.pushStack(
+           jQuery.unique(
+               jQuery.merge( this.get(), jQuery( selector, context ) )
+           )
+       );
    },

    addBack: function( selector ) {
@@ -3975,8 +3971,7 @@ var rcheckableType = (/^(?:checkbox|radio)$/i);


 (function() {
-   var input,
-       fragment = document.createDocumentFragment(),
+   var fragment = document.createDocumentFragment(),
        div = fragment.appendChild( document.createElement( "div" ) );

    // #11217 - WebKit loses check when the name is after the checked attribute
@@ -3986,12 +3981,10 @@ var rcheckableType = (/^(?:checkbox|radio)$/i);
    // old WebKit doesn't clone checked state correctly in fragments
    support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;

-   // Make sure checked status is properly cloned
-   // Support: IE9, IE10
-   input = document.createElement("input");
-   input.type = "checkbox";
-   input.checked = true;
-   support.noCloneChecked = input.cloneNode( true ).checked;
+   // Make sure textarea (and checkbox) defaultValue is properly cloned
+   // Support: IE9-IE11+
+   div.innerHTML = "<textarea>x</textarea>";
+   support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
 })();
 var strundefined = typeof undefined;

@@ -6784,8 +6777,11 @@ jQuery.fx.tick = function() {
 };

 jQuery.fx.timer = function( timer ) {
-   if ( timer() && jQuery.timers.push( timer ) ) {
+   jQuery.timers.push( timer );
+   if ( timer() ) {
        jQuery.fx.start();
+   } else {
+       jQuery.timers.pop();
    }
 };

@@ -7301,14 +7297,6 @@ jQuery.fn.extend({

 jQuery.extend({
    valHooks: {
-       option: {
-           get: function( elem ) {
-               // attributes.value is undefined in Blackberry 4.7 but
-               // uses .value. See #6932
-               var val = elem.attributes.value;
-               return !val || val.specified ? elem.value : elem.text;
-           }
-       },
        select: {
            get: function( elem ) {
                var value, option,
@@ -9111,7 +9099,9 @@ jQuery.noConflict = function( deep ) {
 // Expose jQuery and $ identifiers, even in
 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
 // and CommonJS for browser emulators (#13566)
-window.jQuery = window.$ = jQuery;
+if ( typeof noGlobal === strundefined ) {
+   window.jQuery = window.$ = jQuery;
+}

mattfenwick avatar Jan 29 '14 14:01 mattfenwick

Removing the (window) calls fixed it for me: https://github.com/ccoenraets/directory-backbone-browserify/pull/2

mattfenwick avatar Jan 29 '14 14:01 mattfenwick

+1 @mattfenwick The same solution works for me. What could have been the problem?

xander-mbaka avatar Nov 30 '16 12:11 xander-mbaka