我无法在提交表单时触发Polymer函数:
<form onsubmit="return _submit()"> //_submit is not defined
<form onsubmit="return this._submit()"> //this._submit is not a function
<form onsubmit="_submit"> //_submit is not defined
<form onsubmit="{{_submit}}"> //no output
<form on-submit="{{_submit}}"> //no output
<form on-submit="_submit"> //no output
如何绑定到Polymer函数?
答案 0 :(得分:0)
使用iron-form
:
<form is="iron-form" id="form" method="post" action="/form/handler">
<paper-input name="name" label="name"></paper-input>
<input name="address">
...
</form>
然后为表单提交后触发的iron-form-submit
添加一个监听器:
Polymer({
listeners: {
'iron-form-submit': '_handleSubmit'
},
_handleSubmit: function(e) {
// Do something
}
})
有关详细信息,请参阅iron-form docs。