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

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).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

define

this code can’t work

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

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

function clickElem (e) {
    console.log('elem clicked');
    var classes = $$(this).attr('class').split(' ');
    var id = classes[1];
    console.log(id);
}

myApp.onPageInit('*', function (page) {
    $$(page.container).off('click', clickElem);
    $$(page.container).on('click', clickElem);
});