mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 09:14:58 +02:00
Add support for an Inputfield "changed" JS event in inputfields.js
This commit is contained in:
@@ -105,6 +105,7 @@
|
||||
* - columnWidth: Triggered on .Inputfield when an API call to set column width, receives width percent after event argument.
|
||||
*
|
||||
* Other events:
|
||||
* - changed: Triggered on an .Inputfield that has an input element within it changed (3.0.184+)
|
||||
* - AjaxUploadDone: Triggered on an .Inputfield element after a file has been ajax-uploaded within it.
|
||||
*
|
||||
* ATTRIBUTES
|
||||
@@ -2170,16 +2171,18 @@ function InputfieldStates($target) {
|
||||
});
|
||||
|
||||
// confirm changed forms that user navigates away from before submitting
|
||||
$(document).on('change', '.InputfieldFormConfirm :input, .InputfieldFormConfirm .Inputfield', function() {
|
||||
$(document).on('change', '.InputfieldForm :input, .InputfieldForm .Inputfield', function() {
|
||||
var $this = $(this);
|
||||
if($this.hasClass('Inputfield')) {
|
||||
// an .Inputfield element
|
||||
if(!$this.hasClass('InputfieldIgnoreChanges')) $this.addClass('InputfieldStateChanged');
|
||||
return false;
|
||||
if($this.hasClass('InputfieldIgnoreChanges')) return false;
|
||||
$this.addClass('InputfieldStateChanged').trigger('changed');
|
||||
// .InputfieldFormConfirm forms stop change at parent .Inputfield element
|
||||
if($this.closest('.InputfieldFormConfirm').length > 0) return false;
|
||||
} else {
|
||||
// an :input element
|
||||
if($this.hasClass('InputfieldIgnoreChanges') || $this.closest('.InputfieldIgnoreChanges').length) return false;
|
||||
$this.closest('.Inputfield').addClass('InputfieldStateChanged');
|
||||
$this.closest('.Inputfield').addClass('InputfieldStateChanged').trigger('changed');
|
||||
}
|
||||
});
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user