# Event listener on body is not being removed

**URL:** https://discuss.hotwired.dev/t/event-listener-on-body-is-not-being-removed/2780
**Category:** General
**Created:** [May 1, 2021, 10:57pm UTC](https://discuss.hotwired.dev/t/event-listener-on-body-is-not-being-removed/2780 "2021-05-01T22:57:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rockwell](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/rockwell/32/1884_2.png) [@rockwell](https://discuss.hotwired.dev/u/rockwell)
#### Post date: [May 1, 2021, 10:57pm UTC](https://discuss.hotwired.dev/t/event-listener-on-body-is-not-being-removed/2780/1 "2021-05-01T22:57:48Z")

</div>

Hi, so i have this event listener

```auto
  connect() {
    console.log("connecting it")
    if(this.attachToBodyValue) {
      document.addEventListener("scroll", this.bodyScrollListener.bind(this));
      return;
    }
  }

  disconnect() {
    document.removeEventListener('scroll', this.bodyScrollListener.bind(this));
    super.disconnect();
  }

```

The thing is, when i navigate away from the page, the function is still there, and if i navigate to the bottom it will go to the infinite-scroll URL. this is the result of `getEventListeners(document) before leaving the page.

 ![Screenshot 2021-05-02 at 01.55.34](https://canada1.discourse-cdn.com/flex027/uploads/stimulusjs/original/2X/d/d26d44ba1c7c66ffadff3951fb6ab38d8aa4067e.png)

and after leaving the page, the same call to `getEventListeners(document)` will get the same result back, the listener isnt being removed for some reason.

Any ideas are greatly appreciated, thanks

---

<div class="post-metadata">

### Author: ![rockwell](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/rockwell/32/1884_2.png) [@rockwell](https://discuss.hotwired.dev/u/rockwell)
#### Post date: [May 1, 2021, 11:06pm UTC](https://discuss.hotwired.dev/t/event-listener-on-body-is-not-being-removed/2780/2 "2021-05-01T23:06:28Z")

</div>

turns out i was missing javascript 101.

i had to bind only in `initialize`
