This is quite a handy event - it indicates that focusOut has happened _and_ that the value has changed. The only way to achieve this AFAICT is to store the previous value and compare, which is pretty tedious. Also it seems quite unexpected that focus-out="doSomething" works, but change="doSomething" doesn't.
I know that I can use observers, but in my case I only want to run the action on focusOut.
For anybody interested my workaround is to use an on-change event:
// app/components/change-input.js
// Usage: {{change-input on-change="doSomething"}}
export default Ember.TextField.extend({
change: function(event) {
this._elementValueDidChange();
this.sendAction('on-change', this, event);
}
});
@aexmachina Are you suggesting that we add a new event type?
No I'm not, but it would be good if the TextField did emit the change event. I find it unexpected that it's not provided.
i think that the change event should be triggered, it keeps the normal behaviour of text inputs and avoids additional code, I think it's quite useful for user input validation stuff
Is there any reason why the change event is not triggered?
I have to admit that monkey patching the textfields and textareas to emit a change event is one of the first things I do on ember projects. It does seem like a strange omission.
@aexmachina I think this works now: http://guides.emberjs.com/v2.0.0/templates/input-helpers/#toc_actions
Feel free to close this issue if you feel that this has been resolved.
I've tried this but it doesn't appear to work. Also, there's no mention of the change event in the doc link you sent.
I'm using the latest ember-cli and components/ember#canary. I can send you the example project, but it's as simple as this:
templates/application.hbs
{{input change='foo'}}
If I change this to {{input key-press='foo'}} it works.
controllers/application.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
foo: console.log.bind(console)
}
})
A few other things:
Event instance as indicated in the docsWhy has this simply been closed? I'm missing exactly this feature right now. IMO the request is reasonable, no-one has objected to that, and there was even a pull request. And still, it was closed without even any reasoning as to why not supporting it.
At least it could be kept open, if there is no time to fix it now.
Most helpful comment
Why has this simply been closed? I'm missing exactly this feature right now. IMO the request is reasonable, no-one has objected to that, and there was even a pull request. And still, it was closed without even any reasoning as to why not supporting it.
At least it could be kept open, if there is no time to fix it now.