1

I'm getting an Uncaught TypeError when i refresh the page, my js/app/main.js file can't call the method update() on js/app/utilities/resize.js.

Error output

Uncaught TypeError: Object function U(n){return n&&typeof n=="object"&&!me(n)&&ne.call(n,"wrapped")?W(n)} has no method 'update'

I haven't managed to isolate/replicate the issue into a simplified working example unfortunately. But you can click on the js files within the folder tree below for gists.

  • index.html
  • js /
    • app.js
    • lib /
      • require.js
      • jquery.js
      • ... etc
    • app /
      • main.js - Uncaught TypeError @line 566
      • utilities /

app.js

require.config({

    urlArgs: "bust=" + (new Date()).getTime(),

    baseUrl: WP.THEME_URL+"/js",

    paths: {
        app     : "app"
        , jquery  : "lib/jquery-2.0.2.min"
        , ...
        , resize    : "app/utilities/resize" 
        , ...
    }
});

require(["app/main"],function(){});

The method update() is being called on resize.js from main.js;

main.js

define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize ) {

...

function setup() {

 resize.update(); // Uncaught TypeError happens here

}

$doc.ready( setup );

resize.js

define([],function () {   

    var resizeItems = [],
        update = function () {

            for (i = 0; i < resizeItems.length; i++){
                var item = resizeItems[i];
                item.callback( App.screen.width , App.screen.height );
            }
        };

    return {
        update  : update,
        add     : function( item ) { resizeItems.push( item ); }
    }
});

Thanks in advance


Edit : It seems it was a dependancy issue. Adding "resize" to require on app.js has resolved it;

require(["resize","app/main"],function(){});

I thought suppling "resize" to define() in main.js would have ensured correct deps;

define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize )...
1
  • It seems it was a dependancy issue. see Edit. Commented Jun 11, 2013 at 9:57

1 Answer 1

1

It seems it was a dependancy issue.

Adding "resize" to require() within app.js has resolved it;

require(["resize","app/main"],function(){});

I thought suppling "resize" to define() in main.js would have ensured correct deps;

define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize )...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.