Skip to content

Consider triggering change event after reverting to previous value #50

@rickarubio

Description

@rickarubio

Hi @AlphaGit, I'm currently using ng-pattern-restrict with a slight modification:

Original Version:

function revertToPreviousValue() {
  iElement.val(oldValue);

   if (!angular.isUndefined(caretPosition)) {
     setCaretPosition(caretPosition);
    }
}

Normally, whenever a user changes the input value, a change event is automatically fired. Many other 3rd party directives such as angular-floating-labels depend on an input or change event to be triggered to take some action.

val() will not trigger any events to be fired, so when the value is reverted, any other directives which may also be applied to an input will be unaware of the changes made by val().

Is this something that was omitted by design?

If not, would you like me to submit a pull request to add this in?

Modified Version:

function revertToPreviousValue() {
  iElement.val(oldValue);
  iElement.trigger("change");

   if (!angular.isUndefined(caretPosition)) {
     setCaretPosition(caretPosition);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions