[Vuejs]-Vue method scope, return from if statement not returning

0๐Ÿ‘

@skirtle, thank you, you just did something to my brain with the confusion of invocations. It was entirely my thinking fail.

Solved code below

checkUser(user) {
      if (this.$store.getters.isAdmin) {
        return true;
      }

      if (this.$store.getters.isDeleg) {
        return user.subteam_id === this.$store.state.user.subteam_id;
      }
    }

Explanation

I was checking for the passed user.admin from v-for, but I needed to check for user.admin of currently logged in user (if he can edit the content, then bind that attribute to true/false). As I have this already in vuex I just grabbed it with getter and returned true (working as you said).

I hope it makes sense. Thanks once again, I was stuck and you helped me.

@Jacob, I am just binding contenteditable to true/false with this function.

Leave a comment