0

I already tried searching everywhere how to get the current element and got onto this get action target element in ember, but he's using Views action to get the element on click. Even this one Emberjs: Get the current element is using also view to get it(though the target="TasksView" on action I don't actually get it. What was the parameters on target anyway? lol ) So I am opening this thread to get an element via router.

ex.

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>
Community
  • 1
  • 1
olanchuy
  • 405
  • 1
  • 4
  • 13
  • What do you mean by element? The dom element? – Patsy Issa Oct 17 '14 at 17:08
  • You need the view to get the element. But it is very rare to need the actual dom element. Usually you can achieve your goal without the element. What is it exactly that you are trying to do with the element from the route? – Patsy Issa Oct 17 '14 at 17:16
  • I want on that element is the freedom lol. The animation(using jquery animate, I'm not using css animations/transitions to animate just for future purposes if this is possible), appending/prepending, actually anything. I'll rewrite my example so that my purpose is clearer. – olanchuy Oct 17 '14 at 17:26
  • If you want the element you ll have to get it from the view, the route is not meant to handle it – Patsy Issa Oct 17 '14 at 17:47
  • I see, so there's no other way around it huh. That makes sense and understandable I think so that it will only have one source. – olanchuy Oct 17 '14 at 18:14
  • can you expand on what you're trying to achieve? Is it just applying animations? becuase you can do that in the view can't you? – Jakeii Oct 18 '14 at 04:38

0 Answers0