ember-rapid-forms
ember-rapid-forms copied to clipboard
Support for autocomplete attribute in em-* helpers
As title says, I'd like to be able to pass, for example, autocomplete='off'
to {{em-input}}
. Ember's {{input}}
helper allows for this, but with {{em-input}}
, this doesn't work:
{{em-input property="X" placeholder="X" autocomplete='off'}}
This is a known issues, the current solutions is to add all of these bindings referencing the parent component. Which IMHO is not the best solution, but I still don't know of a better way of passing parameters from a parent component to one of its child.
I'm writing about this because on FireFox it auto-selects first <option>
with value
attribute(I'm not sure, but it seems to work this way) in <select>
(doesn't matter if prompt
is present). So I tried passing autocomplete
attribute but since it's impossible(and autocomplete
just on <form>
is not sufficient) I came up with following code, which does what I want:
import EmFormComponent from 'ember-rapid-forms/components/em-form';
EmFormComponent.reopen({
attributeBindings: ['autocomplete', 'role'],
deselectOnFF: Ember.on('didInsertElement', function() {
// console.log('Deselect on FF.');
let isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
if (isFirefox) {
// console.log('Children:');
let selects = $(this.get('element')).children().children().children('select');
// console.log(selects);
selects.val(null);
}
})
});
The problem with that is. If you insert that code when you load a form which represents a loaded model with the propert set to some value you gonna delete it, right? I will try to incorporate this change into [email protected] (See https://github.com/piceaTech/ember-rapid-forms/pull/44)