9

I have an event in vuejs

methods: {
   filterPeople: function filterPeople() {
      $(event.target).closest('li').addClass('active');
});

In firefox I get an error

TypeError: event is undefined
mounted/<
re/e.prototype.$emit
filterPeople

Any idea why this does not work in FF

Zakaria Acharki
  • 65,304
  • 15
  • 70
  • 95
LeBlaireau
  • 16,087
  • 30
  • 105
  • 176

3 Answers3

4

Firefox doesn't have a global event object.

WebKit follows IE's old behavior of using a global symbol for "event", but Firefox doesn't.

Simply add it as a parameter.

methods: {
  filterPeople: function filterPeople(event) {
    $(event.target).closest('li').addClass('active');
  }
}
Bert
  • 76,566
  • 15
  • 189
  • 159
1

You must pass the event as parameter, should be :

methods: {
  filterPeople: function(event) {
    $(event.target).closest('li').addClass('active');
  }
}

NOTE : The name was duplicated in the function definition.

Hope this helps.

Zakaria Acharki
  • 65,304
  • 15
  • 70
  • 95
0

Pass event to function filterPeople(). Like this:

methods: {
  filterPeople: function filterPeople (e) {
  $(e.target).closest('li').addClass('active');
});