← Back to Upcase

Hands on Backbone.js 'no method'

(Joey Parshley) #1

Can someone show me what is wrong here? Im in the validations part of the workshop:

class App.Models.Note extends Backbone.Model

validate: ->
unless @hasTitle() or @hasContent()
“Needs title or content”

hasTitle: -> @hasAttribute(‘title’)
hasContent: -> @hasAttribute(‘content’)
hasAttribute: (attr) -> @has(attr) && @get(attr).trim( ) != “”

Results in Uncaught TypeError: Object # has no method ‘hasTitle’ and I cannot see why???

(Joey Parshley) #2

Found it my hasTitle, hasContent and hasAttribute methods were indented :-/