Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuejs event not working in firefox - fine in Chrome

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

like image 485
LeBlaireau Avatar asked Sep 08 '17 15:09

LeBlaireau


2 Answers

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');
  }
}
like image 140
Bert Avatar answered Oct 02 '22 09:10

Bert


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.

like image 34
Zakaria Acharki Avatar answered Oct 02 '22 10:10

Zakaria Acharki