Created
July 9, 2013 16:38
-
-
Save timhudson/5958935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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