防止纸质对话框关闭确认按钮

时间:2014-10-28 17:03:43

标签: javascript jquery polymer paper-elements

我有一个提交表单的纸质对话框,在提交时,将从服务器收到任何错误。如果有错误,它们将显示在对话框中。我想处理click事件,如果没有错误,请关闭对话框

<paper-dialog id="addSecretModal" heading="Add secret" transition="paper-dialog-transition-center">
     <paper-input id="dirInput" floatinglabel label="Directory" layout vertical class></paper-input>
     <paper-input id="secretInput" floatinglabel label="Directory" layout vertical class></paper-input>
    <paper-button dismissive>Cancel</paper-button>
    <paper-button id="confirmAddSecret" affirmative autofocus>Accept</paper-button>
</paper-dialog>

我试图删除肯定,但由于Polymer处理对话框的方式,这会弄乱样式。肯定按钮不会在正确的位置结束,而是在不屑一顾的按钮上方。我读到了closeSelector =&#34;&#34;会解决它,但无济于事。无论如何我能做到吗?

1 个答案:

答案 0 :(得分:2)

我找到了一个解决方案,而且我觉得这样做有点像白痴。我将closeSelector=""放在纸质按钮标签中,而不是纸张对话框标签中。通过closeSelector="[dismissive]"

,我也想出了如何使它变得如此不屑一致仍然有效
<paper-dialog id="addSecretModal" heading="Add secret" transition="paper-dialog-transition-center" closeSelector="[dismissive]">
     <paper-input id="dirInput" floatinglabel label="Directory" layout vertical class></paper-input>
     <paper-input id="secretInput" floatinglabel label="Directory" layout vertical class></paper-input>
    <paper-button dismissive>Cancel</paper-button>
    <paper-button id="confirmAddSecret" affirmative autofocus>Accept</paper-button>
</paper-dialog>