I have been using Backbone a lot lately and love it because it keeps my code clean.
I am just building another site and I really want to use some of the backbone / coffeescript syntax. For example for a one page loader I was thinking of doing something like this:
This is a single HTML page that loads one JavaScript file
#query Events
$(document).ready =>
$(".click").click ->
console.log "hello"
alert()
#Functions
alert: ->
console.log "alert"
So I can split all my functions neatly below and the events at the top. So I can keep track. In the above example I am trying to get the click event to fire on alert.
In backbone I can have an events list which trigger alerts, which I find really useful. But I do not need all the views / controllers / models etc.
At the moment though this does not work. What is the best way to have an event fire another function outside of its own function?
Maybe I am doing this really wrong, but I love the simplicity of splitting this up and keeping it clean.
Okay so i messed up my syntax quite a bit…
Works, if anyon else is looking to do this then this has worked for me 🙂