From f4b1c586bb19f4f4dd22a961496dc59250f50baa Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 28 May 2016 13:02:54 +1000 Subject: [PATCH] Clicking a non-submit type link should allow event propagation This is useful when an AJAX request link appears inside something like a dropdown. When the link is clicked, the dropdown should close like normal, however this is not the case since the value `false` is returned; so the expected behavior doesn't occur. As a solution, `false` is no longer returned, the default behavior on the event is prevented instead, allowing the propagation to proceed as normal. --- modules/system/assets/js/framework.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/system/assets/js/framework.js b/modules/system/assets/js/framework.js index 3eb79f996..fba03a8b3 100644 --- a/modules/system/assets/js/framework.js +++ b/modules/system/assets/js/framework.js @@ -369,9 +369,13 @@ if (window.jQuery === undefined) $(this).request() }) - $(document).on('click', 'a[data-request], button[data-request], input[type=button][data-request], input[type=submit][data-request]', function documentOnClick() { + $(document).on('click', 'a[data-request], button[data-request], input[type=button][data-request], input[type=submit][data-request]', function documentOnClick(e) { + e.preventDefault() + $(this).request() - return false + + if ($(this).is('[type=submit]')) + return false }) $(document).on('keydown', 'input[type=text][data-request], input[type=submit][data-request], input[type=password][data-request]', function documentOnKeydown(e) { @@ -385,12 +389,13 @@ if (window.jQuery === undefined) }) $(document).on('keyup', 'input[data-request][data-track-input]', function documentOnKeyup(e) { - if (!$(this).is('[type=email],[type=number],[type=password],[type=search],[type=text]')) return - var $el = $(this), lastValue = $el.data('oc.lastvalue') + if (!$el.is('[type=email],[type=number],[type=password],[type=search],[type=text]')) + return + if (lastValue !== undefined && lastValue == this.value) return