打开对话框后设置焦点 - 聚合物(无 JQuery)



一个地方在打开paper-dialog时如何关注它所包含的paper-input

我目前有这个基本代码作为概念证明,但它不会有重点。

我发现这适用于paper-input中编写的autofocus,但我认为这不是合适的方法。

.HTML

<paper-dialog style="margin:0; padding: 0;" class="changePictureDialog" id="dialog" with-backdrop entry-animation="scale-up-animation" 
exit-animation="fade-out-animation">
<paper-input style="margin:20px" id="newInput" placeholder="placeholder"></paper-input>
<paper-button id="button" on-click="focusInput">button</paper-button>
</paper-dialog>

.JS

openDialog : function() {
this.$.dialog.open();
this.$.newInput.focus();
},

更改以下内容:

this.$.newInput.focus();

自:

this.$.newInput.autofocus = true;

最新更新