{"id":6062,"date":"2014-04-12T02:58:40","date_gmt":"2014-04-12T02:58:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/12\/strange-issue-with-javascript-asset-mootools-collection-of-common-programming-errors-2\/"},"modified":"2014-04-12T02:58:40","modified_gmt":"2014-04-12T02:58:40","slug":"strange-issue-with-javascript-asset-mootools-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/12\/strange-issue-with-javascript-asset-mootools-collection-of-common-programming-errors-2\/","title":{"rendered":"strange issue with javascript.Asset mootools-Collection of common programming errors"},"content":{"rendered":"<p>Hi there dear Collegue,<\/p>\n<p>I&#8217;ve a strange issue with the Javascript.asset method in mootools. i&#8217;ve the following source:<\/p>\n<pre><code>window.addEvent('domready', function(){\n    var g = new geo();\n\n});\n\nvar geo = new Class({\n    initialize: function(){\n        var out = $(\"out\");\n\n        if (!navigator.geolocation){\n            out.set(\"html\",\"<br \/>Geolocation is not supported by your browser<br \/><br \/>\"); \n            return;\n        }   \n\n        this.loadGoogleApi();\n    },\n\n    loadGoogleApi:function(){\n        var myScriptB = Asset.javascript('https:\/\/maps.googleapis.com\/maps\/api\/js?v=3.exp&amp;sensor=false', {\n                id: 'myScript',\n                onLoad: function(){\n                    console.log(myScriptB);\n                }\n        });\n    },\n\n    findCity: function(position){\n\n        var latitude  = position.coords.latitude;\n        var longitude = position.coords.longitude;\n\n        var geoCoder = new google.maps.Geocoder();\n        var latlng = new google.maps.LatLng(latitude,longitude);\n\n         geoCoder.geocode({'latLng': latlng}, function(results, status){\n            this.parseTemplate(results, status);\n         }.bind(this));\n\n    },\n\n    parseTemplate: function(results, status){\n        var adressResult = results[19].formatted_address;\n        var sp = adressResult.split(\",\");\n        var adress = sp[0];\n\n        console.log(adress);\n    },\n\n\n    getLocation: function(){\n        navigator.geolocation.getCurrentPosition(function(response){\n            this.findCity(response);\n        }.bind(this),null);\n    }\n\n});\n<\/code><\/pre>\n<p>When i run this code in my browser (Chrome) i get the following error: Uncaught ReferenceError: Asset is not defined..<\/p>\n<p>when i add the javascript in my plain html text in the section it will work. So the only reason i can come with is that the Asset method isnt working properly.<\/p>\n<p>Can anybody here please help me because.. i&#8217;m working on this issue now for some hours and just can&#8217;t figure out what the issue is.<\/p>\n<p>thanks in Advance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi there dear Collegue, I&#8217;ve a strange issue with the Javascript.asset method in mootools. i&#8217;ve the following source: window.addEvent(&#8216;domready&#8217;, function(){ var g = new geo(); }); var geo = new Class({ initialize: function(){ var out = $(&#8220;out&#8221;); if (!navigator.geolocation){ out.set(&#8220;html&#8221;,&#8221;Geolocation is not supported by your browser&#8221;); return; } this.loadGoogleApi(); }, loadGoogleApi:function(){ var myScriptB = Asset.javascript(&#8216;https:\/\/maps.googleapis.com\/maps\/api\/js?v=3.exp&amp;sensor=false&#8217;, [&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-6062","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6062","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=6062"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6062\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}