I'm trying to implement something to close all menus/modals when a user clicks outside of the menu/modal area.
this.closeMenu()
is being invoked correctly but I'm getting an error that says this.closeMenu is not a function
. What's the reason for this?
methods: Object.assign({},
{
closeMenu(){
console.log("close menu")
}
}
)
mounted(){
$(document).on('click', function(event) {
if (!$(event.target).closest('.menu').length){
// close all menus
this.closeMenu()
}
});
}