Is there a way to determine if a select element's change event was performed by user versus via code (dom manipulation)?
I have a timer that auto sets some select values based on some condition and then formats the select color to signify "success" (green select box).
Because I have the form set to fire off an ajax request when the select change event is fired, it does this for both the timer-based changes to the selects, as well as user-based select changes.
I'd like to only fire that ajax event when it's a user-based select change.
Is this possible?
EDIT:
When I output the value of e.isTrusted, it says Undefined in the log.
Here is my code:
$(document).on('change', 'select', function (e) {
e.preventDefault();
console.log(e.isTrusted); // This outputs "Undefined"
if (e.isTrusted) {
save_review();
console.log("Point status changed by user - Saved");
} else {
console.log("Point status changed programmatically - Not Saved");
}
});