I'm currently creating a game with Javascript and HTML using an MVC design pattern. However, when uploading to the cafe I'm using, I keep getting an error that my View.js class is not being defined in the Controller.js class. However, as by the snippet of code below, you can see that it is:
"use strict";
var model = new Model(),
view = new View(),
controller = null;
function Controller(){
this.init = function(){
view.playGame();
}
}
I also have included the relevant javascript classes within script tags on the single html sheet I'm using. The error message I get in the Chrome debugger is "Uncaught ReferenceError View not defined in Controller.js" Does anybody know why this has started happening? As I have been working on this project for a while and this is the first time it has happened.
Related
I tried to learn backbone with marionette .I started learning from this book and make simple program
marionette-gentle-introduction-sample.pdf
I am getting this error
this._initializeRegions is not a function
here is my codepen
http://codepen.io/anon/pen/epvoVm
var app =Marionette.Application();
app.staticView=Marionette.ItemView.extend({
e1:"#main-region",
template: "#static-template"
})
app.on('start',function(){
console.log('---')
var staticView = new ContactManager.staticView();
staticView.render();
})
app.start()
I didn't get any console message but I am getting error on console
Uncaught TypeError: this._initializeRegions is not a function
Morning
I'm not to sure on marionette but I believe you need to call a new instance of the application. I tested and it seems to work.
var app = new Marionette.Application();
I am receiving Uncaught TypeError: Cannot read property 'length' of undefined error on the load of a certain page of my ionic app.
Because this error points to a file in the core, I am clueless as to how to debug this. I have performed breakpoints throughout the controller file and I am unable to pin it down.
The error comes up after the full page has loaded.
Hopefully this picture paints a 1000 words.
EDIT
I have now tracked this issue to this piece of code.
$ionicModal.fromTemplateUrl('templates/exercise-modal.html', {
scope: $scope
}).then(function (addExerciseModal) {
$scope.addExerciseModal = addExerciseModal;
});
// Triggered in the exercise modal to close it
$scope.closeAddExerciseModal = function() {
$scope.addExerciseModal.hide();
};
// Open the exercise modal
$scope.OpenAddExerciseModal = function() {
$ionicSlideBoxDelegate.slide(0);
$scope.addExerciseModal.show();
};
However I use this elsewhere in my app and it functions just fine..?
Clearly, slides is undefined at the time that line is executing. Look backwards through the source code - a few lines above that you should see something that lets you know what slides is expected to be (if you don't already know).
Then look at how slides is being created/provided, and follow it back to your own code.
I am new to typescript and am trying to get a simple class going. I have the below code and when I run, I keep getting a syntax error. I tried even an empty class and nothing.
I am using ASP.NET MVC5 (note, if I just have a function in the code, it works fine).
Inside Site.ts I have:
class Facebook {
constructor() { }
open() {
window.open("http://www.facebook.com");
}
}
var social = new Facebook();
I am calling the code by a link
open
I don't even get to click, right away, when loading I get
JavaScript critical error at line 1, column 1 in http://localhost:20870/Scripts/site.ts\n\nSCRIPT1002: Syntax error
It seems to work in the playground:
Click here to see my workout
Any ideas?
Looks like the browser is trying to execute the TypeScript and not the JavaScript. Double check your <script> tags (or any other thing you are using to load the code e.g. requirejs)
I had the same problem, when using a TypeScript tutorial on www.typescriptlang.org.
I realized that my script tag was referencing the TypeScript file and not the JS file:
<script src="greeter.ts"></script>
instead of:
<script src="greeter.js"></script>
Hi have an Windows Store App that need to reference a single Winmd file.
I've added it adding as a normal DLL, that's the correct way?
As my understanding I'm trying to "instantiate" it on my default.js as below:
var helloTest = new WinJS.HelloWR.HelloRT();
With that I'm able to access its methods as:
var ret = helloTest.helloRt();
The problem happens when I try to run it, it raises the following exception:
0x800a138f - JavaScript runtime error: Unable to get property 'HelloRT' of undefined or null reference
It means that my HelloWR namespace is undefined, I've been looking around google for some similar sample but I've found anything.
Let me know if anyone need more info about the content of this winmd.
For those whom faces the same problem, I just did as below:
var helloTest = new HelloWR.HelloRT;
It's not needed to put WinJS as the question at the Top.
Now I'm able to access its methods:
var ret = helloTest.helloRt();
//ret returns 'HelloRT'
If someone explain it better I will check as answer.
I'm learning backbone.js and already have a problem.
I'm loading my scripts with LABjs like this:
$LAB.setOptions({BasePath : path})
.script('libs/underscore.js?v=1.3.3')
.script('libs/backbone.js?v=0.9.2')
.script('libs/jquery.js?v=1.7')
.script('libs/bootstrap.min.js?v=2.0.2').wait()
.script('test.js');
In my test.js I have this (from backbonetutorials.com):
(function($){
SearchView = Backbone.View.extend({
initialize: function(){
alert("Alerts suck.");
}
});
var search_view = new SearchView;
})(jQuery);
As you see this should give me an alert with text "Alerst suck.".
Instead it throws an error on my firebug console - i is not a function (34 line of backbone.js).
If I try to initialize view like this var search_view = new SearchView({el: $('#some_dom_element')}); it gives me another error - invalid 'instanceof' operand i (34 line of backbone.js file).
jQuery object $ is defined.
I can initialize Backbone.js models without any problems. Just view throws those errors. What I am missing?
It seems that order in which scripts are loaded matters. I've loaded jQuery first now and it started to work. I've also tested it with non minified version of backbone.js and the error was more verbose $ is not a function. So again - loading jQuery before backbone.js fixed it.
EDIT: When loading jQuery after backbone.js when I do console.log($) right before view initialization it shows tha $ is a function. Why backbone.js fails to work then? Can someone explain this?