question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOM event .off('event') does not unbind

See original GitHub issue

This is a (multiple allowed):

  • bug
  • Framework7 Version: 1.4.2
  • Platform and Target: All platforms

What you did

Tried to unbind an event attached to an element.

$$(this.form).off('submit').on('submit', function (e) {
    //...
});

Expected Behavior

Should unbind event and re-attach it.

Actual Behavior

Does not unbind event, as a result the event is bound multiple times (this code is called each time a particular page is inited).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15

github_iconTop GitHub Comments

2reactions
ZanderBrowncommented, Nov 4, 2016

define

this code can’t work

What’s happening? Is the handler being added twice? not at all? What is ‘aa’?

1reaction
ZanderBrowncommented, Mar 30, 2017

because to javascript it’s not the same function because the function would be redeclared in each call of page:init

Read more comments on GitHub >

github_iconTop Results From Across the Web

DOM event .off('event') does not unbind · Issue #1110 - GitHub
Does not unbind event, as a result the event is bound multiple times (this code is called each time a particular page is...
Read more >
jQuery off() is not unbinding events when using bind
The problem is that this._click.bind() creates a new function every time it's called. In order to detach a specific event handler, ...
Read more >
.unbind() | jQuery API Documentation
A string containing one or more DOM event types, such as "click" or "submit," or custom event names. ... The function that is...
Read more >
Binding and unbinding of event handlers - plainJS
It's not required to unbind event handlers when removing DOM elements. JavaScript's garbage collection will take care of it and free up the...
Read more >
jQuery .unbind() Event Method
In this jQuery tutorial reference we learn how to use the .unbind() method to unattach a previously bound event handler(s) from the specified...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found