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
  • 38,111
  • 12
  • 81
  • 101
Miguel Moura
  • 36,732
  • 85
  • 259
  • 481

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
  • 384,651
  • 66
  • 527
  • 531