0

I have the following:

enquire.register(value, {
  match: function () {
    $('nav.menu a[href="#"]').click(function () {
      $(this).next('ul').toggle();
    })
  },
  unmatch: function () {
  }
});

In unmatch, how can I cancel the click event which I set in match?

Adam Lear
  • 36,757
  • 12
  • 82
  • 99
Miguel Moura
  • 32,822
  • 74
  • 219
  • 400

1 Answers1

2

I'll prefer to use a namespaced click event and .off() to remove the handler

enquire.register(value, {
    match: function () {
        $('nav.menu a[href="#"]').on('click.match', function () {
            $(this).next('ul').toggle();
        })
    },
    unmatch: function () {
        $('nav.menu a[href="#"]').off('click.match');
    }
});
Arun P Johny
  • 376,738
  • 64
  • 519
  • 520