Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When assign value not fire change event #20

Open
RicardoBer opened this issue Nov 1, 2018 · 2 comments
Open

When assign value not fire change event #20

RicardoBer opened this issue Nov 1, 2018 · 2 comments

Comments

@RicardoBer
Copy link

If you want, for example, capture onchange event for force only numbers, you can't.

In the same manner you can't catch keypress or so.

Any way, I propouse to add at least onchange event. For this I propouse:

Keyboard.prototype.printChar = function(char) {
  var selStart = this.$current_input[0].selectionStart;
  var selEnd = this.$current_input[0].selectionEnd;
  var textAreaStr = this.$current_input.val();
  var value = textAreaStr.substring(0, selStart) + char + textAreaStr.substring(selEnd);

  this.$current_input.val(value).focus();
++++  this.$current_input.trigger('change'); //ADD THIS FOR FIRE CHANGE EVENT 2018-11
  this.$current_input[0].selectionStart = selStart+1, this.$current_input[0].selectionEnd = selStart+1;

};

Now you can add this:

onchange="this.value=this.value.replace(/[^\d]/,'');"

to any input and force only integer numbers.

@hongtan
Copy link

hongtan commented Oct 30, 2019

Thank you! I was looking for ways to solve it outside of the framework but then I found this.

@kyselejsyrecek
Copy link

Thank you for reporting. The issue is now addressed in kyselejsyrecek@decdfe6 (development version 1.0.1).

Note that the originally proposed fix does not handle deletion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants