From 50dcbc710a065cef782d9b11bc9d15fea4f0d71b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 10 Nov 2013 12:20:07 -0500 Subject: Add new samples when pressing the enter key in the add form --- assets/js/views/sample-add-view.js | 9 ++++++++- index.html | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/js/views/sample-add-view.js b/assets/js/views/sample-add-view.js index 8be2fb8..6fea239 100644 --- a/assets/js/views/sample-add-view.js +++ b/assets/js/views/sample-add-view.js @@ -4,7 +4,8 @@ ClipPlay.Views.SampleAddView = Marionette.View.extend({ url_matcher: /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/, events: { - 'click .js-create-sample': 'on_sample_add' + 'click .js-create-sample': 'on_sample_add', + 'submit .js-add-sample-form': 'hijack_form' }, initialize: function(options) { @@ -12,6 +13,12 @@ ClipPlay.Views.SampleAddView = Marionette.View.extend({ this.$input = this.$('.js-sample-url'); }, + hijack_form: function() { + this.on_sample_add(); + + return false; + }, + add_sample_to_collection: function() { this.collection.add({ url: this.$input.val() diff --git a/index.html b/index.html index 0c9425d..2b1d35c 100644 --- a/index.html +++ b/index.html @@ -21,8 +21,10 @@