I have a custom polymer element that is a form and goes something like this.
Dart script:
@CustomTag('my-form')
class MyForm extends PolymerElement {
@published Function submitFunction;
validateAndSubmit() {
// validate
submitFunction();
}
}
HTML:
<polymer-element name="my-form">
<template>
<button id="submitButton" on-click="{{ validateAndSubmit }}">Submit</button>
</template>
</polymer-element
When the submit button is clicked, the submit function will be called, but as you can see it needs to be set to something first. I am using this element multiple times in one page, and for each form I need it to do something different.
In my main I have this:
@CustomTag('my-form')
class MyCustomForm extends MyForm {
// The below commented out line would work if I only had one form.
// var submitFunction = submitForm1;
submitForm1() {
// do stuff with form 1
}
submitForm2() {
// do stuff with form 2
}
}
And in the HTML:
<my-form id="form1" submitFunction="{{ submitForm1 }}"></my-form>
<my-form id="form2" submitFunction="{{ submitForm2 }}"></my-form>
But this doesn't work. The submitForm functions don't run at all. Any suggestions?