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.
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.
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;
define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize ) {
...
function setup() {
resize.update(); // Uncaught TypeError happens here
}
$doc.ready( setup );
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 )...
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 )...