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
This commit is contained in:
Samuel Georges 2017-03-19 13:54:21 +11:00
parent 6697e00649
commit b6fedfb688

View File

@ -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'))
}