polymer - Iron form not submitting on enter with paper input -


i'm testing out using iron-form custom elements. issue i'm having form not being submitted when press enter. example form right here works on enter:

    <iron-form>       <form id="loginform">         <paper-card heading="welcome back!" elevation="1" animated-shadow="true">             <div class="card-content">               <input type="text" label="username" value="{{username}}">               <input type="text" label="password" value="{{password}}">             </div>             <div class="card-actions">                 <button disabled$="[[fetching]]" type="submit">login</button>             </div>         </paper-card>       </form>     </iron-form> 

i have event listener in connectedcallback method listening iron-form-presubmit event

        connectedcallback() {           super.connectedcallback();            this.addeventlistener('iron-form-presubmit', function(event) {             event.preventdefault();             alert('working')           });         } 

the issue when switch html input elements paper-input elements form no longer submits on enter.

    <iron-form>       <form id="loginform">         <paper-card heading="welcome back!" elevation="1" animated-shadow="true">             <div class="card-content">               <paper-input type="text" label="username" value="{{username}}"></paper-input>               <paper-input type="text" label="password" value="{{password}}"></paper-input>             </div>             <div class="card-actions">                 <button disabled$="[[fetching]]" type="submit">login</button>             </div>         </paper-card>       </form>     </iron-form> 

you can use <iron-a11y-keys> call submit method when [enter] key pressed.

<iron-a11y-keys target="loginform" keys="enter" on-keys-pressed="submit"></iron-a11y-keys> <iron-form id="loginform"> ... </iron-form> 

in custom element definition, add method:

submit: function () {     this.$.loginform.submit(); } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -