From c09e12ca9a0999b87f7e18aa4dd450a5c6884b66 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Fri, 20 Jul 2018 11:18:30 +0200 Subject: [PATCH] Allow removing exercises from collections --- app/assets/javascripts/exercise_collections.js.erb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/assets/javascripts/exercise_collections.js.erb b/app/assets/javascripts/exercise_collections.js.erb index c1995c7e..d1c4aae8 100644 --- a/app/assets/javascripts/exercise_collections.js.erb +++ b/app/assets/javascripts/exercise_collections.js.erb @@ -170,6 +170,15 @@ $(function() { } } }); + + $('.remove-exercise').on('click', function (e) { + e.preventDefault(); + + var row = $(this).parent().parent(); + var exerciseId = row.data('id'); + $('#exercise-list').find('option[value="' + exerciseId + '"]').prop('selected', false); + row.remove() + }); } } });