Skip to content

Instantly share code, notes, and snippets.

@anselmobattisti
Created February 3, 2018 14:10
Show Gist options
  • Save anselmobattisti/ffbea6ee1be85859144850db57c5dd3b to your computer and use it in GitHub Desktop.
Save anselmobattisti/ffbea6ee1be85859144850db57c5dd3b to your computer and use it in GitHub Desktop.
To access this inside a nested function create a local variable and store this in this valiable, like the example above
methods: {
save (evt) {
let self = this
evt.preventDefault()
this.$validator.validateAll().then((result) => {
if (result) {
EventBus.$emit('startLoading')
dbUser.save(this.user)
.then((resp) => {
EventBus.$emit('stoptLoading')
if (!resp.erro) {
swal({
title: i18n.tc('general.successsave'),
type: 'success'
})
} else {
}
})
.catch((e) => {
EventBus.$emit('stoptLoading')
if (e.data.error.code === 11000) {
swal({
title: i18n.tc('user.duplicatedEmail'),
type: 'error'
}).then(() => {
self.$refs.email.focus()
})
} else {
swal({
title: e.data.message,
type: 'error'
})
}
})
}
})
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment