ember-inputmask
ember-inputmask copied to clipboard
how use two masks on v0.4.x?
How to make it possible to insert two masks on v.0.4.x version ?
In v.0.2.x version I did like this:
didRender() {
this._super(...arguments);
this.$('#'+this.get('id')).inputmask({
mask: ['(99) 9999-9999','(99) 99999-9999'],
showMaskOnHover: true,
showMaskOnFocus: true,
clearMaskOnLostFocus: true
});
}
@joseholanda I don't fully understand the question.
In order to have two masks, you simply create two {{input-mask}}
components in your template:
{{input-mask mask='(99) 9999-9999' showMaskOnHover=true showMaskOnFocus=true
clearMaskOnLostFocus=true}}
{{input-mask mask='(99) 99999-9999' showMaskOnHover=true showMaskOnFocus=true
clearMaskOnLostFocus=true}}
The above template should just work. If it doesn't, then It's a bug and we should fix it.
The usage you showed looks like the old 'jQuery' way, not the 'Ember' way.
@leizhao4 , i would like to add two masks in the same field.
Example in v.0.4.x: https://ember-twiddle.com/145699dc1a07bf8b0cdeb42eb03bf90b?numColumns=2&openFiles=twiddle.json%2Ctemplates.components.my-component.hbs
Example in v.0.2.x: https://ember-twiddle.com/cc28839db5094bb00953c0d634f15437?numColumns=2&openFiles=components.my-component.js%2Ccomponents.my-component.js
Ah, I see what you are saying. Unfortunately I don't personally have experience with this use case.
I was assuming that passing an array as mask
would work:
export default Ember.Component.extend({
mask: ['(99) 9999-9999', '(99) 99999-9999']
});
{{input-mask mask=mask}}
But this didn't in my test. So I'm guessing somewhere in the library code only accepts mask
in string format. I need to look deeper to see where this is happening. But I probably won't have enough time in next 2-3 weeks (just moved to a new city and will start a new job). So any help/PR is greatly appreciated.
@joseholanda do alternator masks work for your use case?