# Attaching jquery events to bound items

**URL:** <https://discuss.emberjs.com/t/attaching-jquery-events-to-bound-items/3580>\
**Category:** Uncategorized\
**Created:** [December 12, 2013, 3:09pm UTC](https://discuss.emberjs.com/t/attaching-jquery-events-to-bound-items/3580 "2013-12-12T15:09:18Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![marcioj](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/marcioj/32/10432_2.png) [@marcioj](https://discuss.emberjs.com/u/marcioj)\
**Post date:** [December 12, 2013, 7:19pm UTC](https://discuss.emberjs.com/t/attaching-jquery-events-to-bound-items/3580/3 "2013-12-12T19:19:57Z")

</div>

Probably you are loading data via ajax, so initially the {{each}} helper is empty, because the data isn’t fetched yet. After the view is inserted, doesn’t have any item, `this.$('li').length == 0`, because the ajax is pending. So no events are added. The ajax finish, the {{each}} update because of data binding, but the `didInsertElement` doesn’t trigger again.

You can use the `afterRender` queue and schedule a function to be triggered when the rendering is finished:

```nohighlight
# hbs
{{#each}}
  <li>{{name}}</li>
{{/each}}
<li>this one works</li>

```

```nohighlight
# View
didInsertElement: function () {
  Ember.run.scheduleOnce('afterRender', this, function() {
    this.$('li').click(function (e) { alert('hi') })
  });  
}

```

---

_[View the full topic](https://discuss.emberjs.com/t/attaching-jquery-events-to-bound-items/3580)._
