我已经尝试在任何地方搜索如何获取当前元素并进入此get action target element in ember,但他正在使用“视图”操作来获取点击元素。即使这一个Emberjs: Get the current element也使用视图来获取它(虽然目标=“TasksView”在动作上我实际上没有得到它。无论如何目标上的参数是什么?大声笑)所以我打开这个线程到通过路由器获取元素。
离。
App.PostsRoute = Ember.Route.extend({
actions: {
getElement: function(params) {
// how to get the current DOM element that was clicked from here?
// my purpose is to get the clicked element to remove it in the list
// and maybe send it to the server?
console.log(params); // current object model
console.log(this); // the route itself
}
}
});
// template
<ul>
<li class="get-this" {{action 'getElement' this}}></li>
<li class="get-this" {{action 'getElement' this}}></li>
<li class="get-this" {{action 'getElement' this}}></li>
<li class="get-this" {{action 'getElement' this}}></li>
<li class="get-this" {{action 'getElement' this}}></li>
<li class="get-this" {{action 'getElement' this}}></li>
</ul>