{"id":2897,"date":"2014-03-10T12:11:05","date_gmt":"2014-03-10T12:11:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/require-js-uncaught-typeerror-object-function-has-no-method-collection-of-common-programming-errors\/"},"modified":"2014-03-10T12:11:05","modified_gmt":"2014-03-10T12:11:05","slug":"require-js-uncaught-typeerror-object-function-has-no-method-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/10\/require-js-uncaught-typeerror-object-function-has-no-method-collection-of-common-programming-errors\/","title":{"rendered":"Require.js : Uncaught TypeError: Object function &hellip; has no method-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m getting an Uncaught TypeError when i refresh the page, my <strong>js\/app\/main.js<\/strong> file can&#8217;t call the method update() on <strong>js\/app\/utilities\/resize.js<\/strong>.<\/p>\n<h2><strong>Error output<\/strong><\/h2>\n<pre><code>Uncaught TypeError: Object function U(n){return n&amp;&amp;typeof n==\"object\"&amp;&amp;!me(n)&amp;&amp;ne.\ncall(n,\"__wrapped__\")?W(n)} has no method 'update'\n<\/code><\/pre>\n<p>I haven&#8217;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.<\/p>\n<ul>\n<li><em>index.html<\/em><\/li>\n<li><strong>js \/<\/strong>\n<ul>\n<li><em>app.js<\/em><\/li>\n<li><strong>lib \/<\/strong>\n<ul>\n<li><em>require.js<\/em><\/li>\n<li>jquery.js<\/li>\n<li>&#8230; etc<\/li>\n<\/ul>\n<\/li>\n<li><strong>app \/<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>app.js<\/h2>\n<pre><code>require.config({\n\n    urlArgs: \"bust=\" + (new Date()).getTime(),\n\n    baseUrl: WP.THEME_URL+\"\/js\",\n\n    paths: {\n        app     : \"app\"\n        , jquery  : \"lib\/jquery-2.0.2.min\"\n        , ...\n        , resize    : \"app\/utilities\/resize\" \n        , ...\n    }\n});\n\nrequire([\"app\/main\"],function(){});\n<\/code><\/pre>\n<p>The method <strong>update()<\/strong> is being called on <em>resize.js<\/em> from <em>main.js<\/em>;<\/p>\n<h2><strong>main.js<\/strong><\/h2>\n<blockquote>\n<p>define([ &#8216;require&#8217; , &#8216;jquery&#8217; , &#8230; ,&#8217;resize&#8217; ], function( require , $ , &#8230; , resize ) {<\/p>\n<p>&#8230;<\/p>\n<p>function setup() {<\/p>\n<pre><code> resize.update(); \/\/ Uncaught TypeError happens here\n<\/code><\/pre>\n<p>}<\/p>\n<p>$doc.ready( setup );<\/p>\n<\/blockquote>\n<h2><strong>resize.js<\/strong><\/h2>\n<pre><code>define([],function () {   \n\n    var resizeItems = [],\n        update = function () {\n\n            for (i = 0; i &lt; resizeItems.length; i++){\n                var item = resizeItems[i];\n                item.callback( App.screen.width , App.screen.height );\n            }\n        };\n\n    return {\n        update  : update,\n        add     : function( item ) { resizeItems.push( item ); }\n    }\n});\n<\/code><\/pre>\n<p>Thanks in advance<\/p>\n<p><strong>Edit<\/strong> : It seems it was a dependancy issue. Adding &#8220;resize&#8221; to require on app.js has resolved it;<\/p>\n<pre><code>require([\"resize\",\"app\/main\"],function(){});\n<\/code><\/pre>\n<p>I thought suppling &#8220;resize&#8221; to define() in main.js would have ensured correct deps;<\/p>\n<pre><code>define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize )...\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m getting an Uncaught TypeError when i refresh the page, my js\/app\/main.js file can&#8217;t call the method update() on js\/app\/utilities\/resize.js. Error output Uncaught TypeError: Object function U(n){return n&amp;&amp;typeof n==&#8221;object&#8221;&amp;&amp;!me(n)&amp;&amp;ne. call(n,&#8221;__wrapped__&#8221;)?W(n)} has no method &#8216;update&#8217; I haven&#8217;t managed to isolate\/replicate the issue into a simplified working example unfortunately. But you can click on the js files [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2897","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2897"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2897\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}