diff options
| author | Teddy Wing | 2013-11-09 20:22:49 -0500 |
|---|---|---|
| committer | Teddy Wing | 2013-11-09 20:22:49 -0500 |
| commit | 73ebf518510691539cc691c2ae89aa12bbe9ee81 (patch) | |
| tree | 601e212b22f1d311cd0dae38659ac904bfba47af | |
| parent | 580fae6570577cd69d70978b88c77c640a6b4750 (diff) | |
| download | clip-play-73ebf518510691539cc691c2ae89aa12bbe9ee81.tar.bz2 | |
Sample add: fix some bugs with adding
* Don't add to collection if the input field is empty
* Clear input field after adding
| -rw-r--r-- | assets/js/views/sample-add-view.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/assets/js/views/sample-add-view.js b/assets/js/views/sample-add-view.js index 0eb3349..7080c84 100644 --- a/assets/js/views/sample-add-view.js +++ b/assets/js/views/sample-add-view.js @@ -5,12 +5,25 @@ ClipPlay.Views.SampleAddView = Marionette.View.extend({ initialize: function(options) { this.setElement(options.el); + this.$input = this.$('.js-sample-url'); }, - on_sample_add: function() { + add_sample_to_collection: function() { this.collection.add({ - url: this.$('.js-sample-url').val() + url: this.$input.val() }); + }, + + clear_input: function() { + this.$input.val(''); + }, + + on_sample_add: function() { + if (this.$input.val()) { + this.add_sample_to_collection(); + + this.clear_input(); + } return false; } |
