gpt4 book ai didi

ember.js - 如何在我的 View 中绑定(bind) jquery 事件

转载 作者:行者123 更新时间:2023-12-03 22:23:56 25 4
gpt4 key购买 nike

我想使用一些基于 jquery 和 ember 的第三方库。这个图书馆
像这样在元素上绑定(bind)事件:

$('#an-id')
.bind('anEvent', function (event, params) { ... })

如何将事件 enEvent 捕获到我的 Ember View 中并使用基于 Ember 的事件处理程序。就像是 :
App.MyView = Em.View.create({

myEventHandler: function(event,params) { ....}
})

最佳答案

使用 didInsertElement View 上的回调,当 View 被添加到 DOM 时调用。然后您可以通过 this.$() 访问添加的元素.

App.MyView = Em.View.create({
didInsertElement: function() {
this.$().bind('anEvent', ...);
}
});

关于ember.js - 如何在我的 View 中绑定(bind) jquery 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9735349/

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