ember-rapid-forms icon indicating copy to clipboard operation
ember-rapid-forms copied to clipboard

Support for autocomplete attribute in em-* helpers

Open e00dan opened this issue 9 years ago • 3 comments

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'}}

e00dan avatar Jun 05 '15 11:06 e00dan

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.

pedrokiefer avatar Jun 05 '15 17:06 pedrokiefer

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);
    }
  })
});

e00dan avatar Jun 06 '15 06:06 e00dan

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)

spruce avatar Aug 19 '15 09:08 spruce