Skip to content

Instantly share code, notes, and snippets.

@timhudson
Created July 9, 2013 16:38
Show Gist options
  • Save timhudson/5958935 to your computer and use it in GitHub Desktop.
Save timhudson/5958935 to your computer and use it in GitHub Desktop.
Watchlists.View = Backbone.Marionette.CompositeView.extend({
template: Backbone.Marionette.TemplateCache.get('#watchlists-view'),
itemView: Watchlists.TableItemView,
itemViewContainer: 'tbody',
events: {
'submit .add-form': 'addWatchlist'
},
addWatchlist: function(e) {
var self = this
, $form = this.$el.find('.add-form')
, $input = $form.find('.title-input')
, title = $input.val()
, exists = this.collection.findWhere({title: title})
, model
if (!exists && title.length) {
// This ▾▾▾ is throwing an error! Why?!!
model = this.collection.create({title: title})
}
else {
$form.removeClass('animated shake').addClass('animated shake')
}
return false
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment