From b6fedfb688e2d99461fd62b99bc8412f38502180 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sun, 19 Mar 2017 13:54:21 +1100 Subject: [PATCH] Specify explicit form element This allows request elements external to the form to serialize a target form for use. An example might be a search form at the top of a page, list of results in the middle, then the pagination at the bottom. The pagination would need to target the search form with data-request-form to persist the search query value. This should work with the JS API too, passed as an object, because $($()) is acceptable in jQuery --- modules/system/assets/js/framework.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/system/assets/js/framework.js b/modules/system/assets/js/framework.js index 57c348bc9..8939e069f 100644 --- a/modules/system/assets/js/framework.js +++ b/modules/system/assets/js/framework.js @@ -32,7 +32,7 @@ if (window.jQuery.request !== undefined) { /* * Prepare the options and execute the request */ - var $form = $el.closest('form'), + var $form = options.form ? $(options.form) : $el.closest('form'), $triggerEl = !!$form.length ? $form : $el, context = { handler: handler, options: options } @@ -377,6 +377,7 @@ if (window.jQuery.request !== undefined) { redirect: $this.data('request-redirect'), loading: $this.data('request-loading'), flash: $this.data('request-flash'), + form: $this.data('request-form'), update: paramToObj('data-request-update', $this.data('request-update')), data: paramToObj('data-request-data', $this.data('request-data')) }