Styling native input in Polymer 2.x?

自闭症网瘾萝莉.ら 提交于 2019-12-11 05:06:49

问题


I am trying to implement this answer.

Is there any way to bind an on-click or on-tap event of a <paper-button> to either of the following hidden input elements?

my-form.html
<iron-form>
  <form>
    ...
    <my-buttons></my-buttons>
    ...
    <input hidden type="reset">
    <input hidden type="submit">
  </form>
<iron-form>

Or to trigger those events in any way? i.e., I have dispatched an event from my <paper-button> as follows

my-buttons.html
<paper-button on-tap="_reset">Reset</paper-button>
<paper-button on-tap="_save">Save</paper-button>

<script>
  _reset() {
    // dispatchEvent...
  }
  _save() {
    // dispatchEvent...
  }
</script>

I want to give pretty (Material Design) styling to the buttons I display to the user of my <iron-form>.

I am also watching @notwaldorf's (Monica D's) tutorial here.


回答1:


You don't really need those hidden inputs, as <iron-form> provides an API for the equivalent events. Namely, <iron-form>.submit() and <iron-form>.reset():

// <iron-form id="form">

_reset() {
  this.$.form.reset();
}

_submit() {
  this.$.form.submit();
}

demo



来源:https://stackoverflow.com/questions/46617616/styling-native-input-in-polymer-2-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!