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
  • 35,439
  • 12
  • 80
  • 98
Miguel Moura
  • 28,129
  • 59
  • 187
  • 356

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
  • 365,836
  • 60
  • 503
  • 504