I am trying to use paper-button
with type
attribute set to submit
(as one would do with button
element) to submit the enclosing form
, but for some reason it is unable to submit the form. Is this a bug or feature?
How to make paper-button
submit the form?
PS: I am in dart land (not js).
There is no need to create a custom element. According to the docs the following apporach is recommended:
so you would just bind the
onclick
event to a function that manually submits your form.UPDATE
Although the previous example from
iron-form
usesonclick
event it is recommended to useon-tap
overon-click
:It is also a good idea to use Polymers own DOM API:
There was already a discussion about using Polymer elements containing form elements within a form in the Polymer Google group and as far as I remember I answered a similar question here on SO (I will do some research afterwards).
1) You can extend an input element
and use it like
2) You can do the form processing in custom code
(read the values from the form elements and create an AJAX call to send the data to the server)
3) Create a custom form element (extends the 2nd)
which does the form processing and AJAX call
The 1st option is not applicable to core-elments/paper-elements because the don't extend an
<input>
(or any other form element) but embed it. This applies to form input elements and also to the form submit button.Some more or less related topics
What you can do if only the submit button is a Polymer element, is to invoke the
click()
method on an invisible (non-Polymer) submit button in the click handler of the<paper-button>
for more details see- Polymer: manually submitting a form
You can achieve the form submit by placing a native button inside the paper-button element:
Then use this following CSS to hide the native button while ensuring it's hitzone fills the entire paper-button element:
As noticed by Gunter, you can create a custom element which extends some of native element with your desired semantics.
I encountered with your issue too and I've created simple element which gives ability to submit to
paper-button
Then you can write this
And will get a button with paper-like look