gpt4 book ai didi

ember.js - 进入 ember 时执行的操作

转载 作者:行者123 更新时间:2023-12-02 13:23:08 25 4
gpt4 key购买 nike

是否有此文本输入

<input type="text" aria-controls="existing-user-table" placeholder="Search">

当用户按回车键时触发 Controller 上的操作?

我不喜欢将其包含在表单标记中或创建按钮,只是输入文本字段。

最佳答案

使用 {{input}} 帮助器 - 如果您包含操作参数,当用户按 Enter 键时,它将在 Controller 上触发该操作。所以:

{{input action="myAction" aria-controls="existing-user-table" placeholder="Search"}}

input helper api docs不要提及此功能,但帮助程序只是包装 Ember.TextField

此外,还可以通过指定onEvent property来触发按键操作,而不是输入。 :

{{input action="myAction" onEvent="keypress" aria-controls="existing-user-table" placeholder="Search"}}

关于ember.js - 进入 ember 时执行的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18670588/

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