I'm new to web development, so please have mercy :) I've created a new ASP.NET project with the hot towel template (http://nuget.org/packages/HotTowel/) and added
<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
to index.cshtml. Also, I modified home.html to look like this:
<section>
<div id="editor">
function foo(items) {
var x = "All this is syntax highlighted";
return x;
}
</div>
</section>
At last, I changed home.js:
define(['services/logger'], function (logger) {
var vm = {
activate: activate,
title: 'Home View'
};
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
return vm;
//#region Internal Methods
function activate() {
logger.log('Home View Activated', null, 'home', true);
return true;
}
//#endregion
});
When I run the application, Chrome tells me that ace.js has an Uncaught TypeError: Cannot read property 'env' of null. Of course, the home screen won't show up. What should I do to make it work?
looks like var editor = ace.edit("editor");
line runs before <div id="editor">
is created, make sure home.js script is included after <div id="editor">
or is activated after document.onload event