gpt4 book ai didi

javascript - 如何获取纸对话 polymer 元素的 "confirmed"返回值?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:43:23 25 4
gpt4 key购买 nike

在 Polymer 应用程序中查看以下 html:

<paper-dialog id="confirmation" modal auto-fit-on-attach>
<h2><spring:message code="confirmation" /></h2>
<p>Are you sure ?<p>
<div class="buttons">
<paper-button dialog-confirm><spring:message code="yes" /></paper-button>
<paper-button dialog-dismiss><spring:message code="no" /></paper-button>
</div>
</paper-dialog>

以及以下 JavaScript:

document.querySelector("#confirmation p").innerText = (message === undefined) ? "No message" : message;
document.getElementById("confirmation").toggle();

如何从对话框中获取“已确认”的返回值?

最佳答案

您通常将处理程序附加到对话框上的 iron-overlay-closed 事件以确定它是否被确认,因为 paper-dialog 实现了 PaperDialogBehavior .

所以像这样:

<template is="dom-bind" id="scope">
<paper-dialog id="confirmation" modal auto-fit-on-attach on-iron-overlay-closed="dismissDialog">
<h2><spring:message code="confirmation" /></h2>
<p>Are you sure ?<p>
<div class="buttons">
<paper-button dialog-confirm><spring:message code="yes" /></paper-button>
<paper-button dialog-dismiss><spring:message code="no" /></paper-button>
</div>
</paper-dialog>
</template>

<script>
(function() {
var scope = document.querySelector('#scope');

scope.dismissDialog = function(e) {
console.log(e.detail.confirmed);

if (e.detail.confirmed) {
// confirmed logic goes here
}
}
})();
</script>

关于javascript - 如何获取纸对话 polymer 元素的 "confirmed"返回值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35778729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com