<form is="iron-form" method="get" action="/" id="feedbackForm">
<paper-textarea name="feedbacks" value="{{feedbackValue::input}}"
label="Explain your feedback - required" required></paper-textarea>
<paper-checkbox name="read" required>You must check this box</paper-checkbox>
<br>
<paper-button class="custom indigo popup" type="submit" raised onclick="submitForm(event)"></iron-icon>
Submit
</paper-button>
<div class="output"></div>
</form>
这是我的剧本:
<script>
function submitForm(event) {
console.log('enfin');
Polymer.dom(event).localTarget.parentElement.submit();
console.log(Polymer.dom(event).localTarget.parentElement);
}
feedbackForm.addEventListener('iron-form-submit', function (event) {
this.querySelector('.output').innerHTML = JSON.stringify(event.detail);
});
Polymer({
is: 'at-feedback-panel',
});
</script>
有人知道用铁形式发生了什么吗?当我尝试这个时,我的浏览器告诉我feedbackForm是未知的。
答案 0 :(得分:1)
事件监听器:
document.getElementById('feedbackForm').addEventListener('iron-form-submit', function (event) {
this.querySelector('.output').innerHTML = JSON.stringify(event.detail);
});
script
$(document).ready(function(){...})
代码
醇>
看起来像:
<script>
$(document).ready(function({
function submitForm(event) {
console.log('enfin');
Polymer.dom(event).localTarget.parentElement.submit();
console.log(Polymer.dom(event).localTarget.parentElement);
}
document.getElementById('feedbackForm').addEventListener('iron-form-submit', function (event) {
this.querySelector('.output').innerHTML = JSON.stringify(event.detail);
});
Polymer({
is: 'at-feedback-panel',
});
}));