15. More reasons...
Flexible UI rendering with no pre-determined templating
Built in LocalStorage and RESTful support
Write once with near-ready-to-deploy mobile code
19. Spine Mobile
Strengthens reason to build around core framework
Extend core components to be mobile ready
Requires minimal additional implementation
23. Module (a.k.a. Spine Class)
Spine’s extension of core CoffeeScript class
Provides class and instance property support
All Spine internals inherit from Spine.Module
31. Controller
Brings it all together
Glues the HTML, DOM manipulation and Model together
Handles all event and UI interaction binding
Extends Spine.Events, allows custom event triggering
32. class UsrGrpsApp extends
↳Spine.Controller
constructor: ->
super
UsrGrp.bind("create",
↳@addOne)
#Bind event handling
33. UsrGrp.bind("create",
↳@addOne)
#Bind event handling
#to DOM elements
events:
"submit form": "create"
"click .deleteAll": "delete"
#DOM Element references
elements:
34. events:
"submit form": "create"
"click .deleteAll": "delete"
#DOM Element references
elements:
"form input": "input"
".list": "list"
#New up a model & render
create: (event) ->
35. "form input": "input"
".list": "list"
#New up a model & render
create: (event) ->
#Prevent form submit
#page load from propagating
event.preventDefault()
#New up a model instance
36. #Prevent form submit
#page load from propagating
event.preventDefault()
#New up a model instance
user = new UserGrp(
↳groupName: @input.val())
#Persist or catch
#validation error
unless user.save()
37. user = new UserGrp(
↳groupName: @input.val())
#Persist or catch
#validation error
unless user.save()
#Very basic notification
alert user.validate()
#Add new element to DOM
38. #Add new element to DOM
#Triggered on create() of Model
addOne: (userGroup) =>
group = new UsrGrps(
↳item: userGroup)
@list.append(
↳$("#listTemplate")
↳.tmpl(userGroup))