view page source - page history - about editing

Revision History: EmberJS

This is revision 368 of the page EmberJS, as it appeared on Mon, 24 Feb 2014 17:06:44 -0800.
Javascript
  1. Adding properties to a model within an EmberJS router

How I learnt EmberJS and Coffeescript and Git


I'll be using the tutorial at http://emberjs.com/guides/getting-started.
  1. Install Sublime Text 2 as an IDE.
  2. Install git and nano. Use nano as the default git commit message editor, because vim support on the Windows command prompt is pretty poor: git config --global core.editor nano
  3. Install the Sublime Linter plugin for ST2, which will provide syntax checking support, by checking out SublimeLinter into your ST2 packages directory (since Sublime Linter is ST3 now): %APPDATA%/Sublime Text 2/Packages by installing Package Control and installing Preferences > Package Control > Install Package > (wait for list to load) > Sublime Linter for ST3 (seems to work OK). This will give you things like PHP syntax error checking.
  4. Install Node.js which will also install NPM (Node.js package manager)
  5. Use npm to install coffeescript: npm install -g coffee-script
  6. Check that coffeescript is working: coffee -v
  7. Install the CoffeeScript ST2 plugin by going Preferences > Package Control > Install Package > (wait for list to load) > CoffeeScript
  8. Sublime Text should now support coffeescript linting. (I couldn't get this to work properly yet.)
  9. Create a file %APPDATA%/Sublime Text 2/Packages/Default/CoffeeScript.sublime-settings and configure ST2 to use spaces rather than tabs for CoffeeScript files.
  10. Edit the csslint settings because they are pretty insane. Preferences > Package Settings > SublimeLinter > Settings - Default and change csslint_options: ids to false, overqualified-elements to false
  11. Create a new Github repository https://github.com/soundasleep/todomvc-emberjs-coffee
  12. Checkout: git clone https://github.com/soundasleep/todomvc-emberjs-coffee
  13. Update push.default on git to a more intuitive value (and also removes a warning): git config --global push.default simple
  14. Follow the instructions in the EmberJS getting started tutorial, committing and pushing as necessary.
  15. Try to Cake building; unfortunately I couldn't get this to work because of win32 problems
  16. Install Grunt for building Coffeescript instead: npm install -g grunt
  17. Install the Grunt CLI: npm install -g grunt-cli
  18. Create a package.json. Understanding package.json
  19. Create a Gruntfile.js.
  20. Install all of the necessary packages referenced in the Gruntfile: npm install grunt-contrib-uglify grunt-contrib-qunit grunt-contrib-concat grunt-contrib-watch --save-dev. --save-dev will also modify package.json with the new dependencies (under devDependencies).
  21. Install https://github.com/gruntjs/grunt-contrib-coffee to compile coffeescript in Grunt: npm install grunt-contrib-coffee --save-dev
  22. You can now compile Coffeescript by running grunt coffee. You can also configure Grunt to watch for new files by modifying your Gruntfile and running grunt watch.
  23. Configure Sublime Text to treat Handlebars templates as HTML: HTML syntax validation within Handlebars templates in Sublime Text 2
  24. Use the js2coffee interpreter a lot
  25. You will have problems with things like function(){...}.property("x"); wrap the function with brackets

DEPRECATION: Action handlers implemented directly on controllers are deprecated in favor of action handlers on an actions object


Can also mean that an error has been thrown and your ApplicationController does not define an 'error' action (or EmberJS has created you an 'error' action and its incorrectly misinterpreting it as a directly implemented action? I have no idea).

This looks like an EmberJS bug and I guess it can be ignored - any other errors will be correctly reported (just sadly with no reliable stacktrace).

arrangedContent.addArrayObserver is not a function


Are you trying to #each over a bare JS object rather than an Ember array? e.g. instead of going:

Todos.TodosIndexRoute = Ember.Route.extend(
	model: ->
		todos: @store.find 'todo'
		feeds: @store.find 'feed'
		# ...
)

{{#each itemController="todo"}}

Going:

{{#each todos itemController="todo"}}


view page source - what links to here? - page history - top
Last edited by jevon jevon 46 months ago