3

I want to show/hide a new div if any of the user links clicked:

<ul id="pm-tabs"> 
  <li v-for="user in unreadMsgsList">       
     <a @click="openPMbox(user)"> ${user}</a>
  </li>
</ul>

the method is:

    openPMbox: function(user) {              
         this.isPmBoxOpenList[user] = !this.isPmBoxOpenList[user];
    }, 

the user data is stored at isPmBoxOpenList: [] and I can verify that it is properly filled.

The window that should show/hide is like this and is out of v-for loop above:

<div class="pmbox" v-bind:disabled=="isPmBoxOpenList" >Some Text </div>

But I get error at template. Not sure how should I define pmbox so appreciate your hints.

P.S. It worths mentioning user is not define in data. It is only an object in isPmBoxOpenList array.

2
  • What is the error you are getting? Commented Mar 17, 2017 at 5:55
  • The error that I get is Uncaught TypeError: Cannot read property 'scrollHeight' of null at WebSocket.<anonymous> (app.js:68) Commented Mar 17, 2017 at 6:06

1 Answer 1

3

You can use v-if, to display or hide like this:

<div class="pmbox" v-if="isPmBoxOpenList[user]" >Some Text </div>
Sign up to request clarification or add additional context in comments.

8 Comments

Well, this gives: ReferenceError: user is not defined. Not surprising as user is not in global context.
in v-if you have to give the variable based on which you want to show or hide the div
Right, but the very question is how to bind that v-if variable to an array variable which is not itself defined as a data variable.
@Karlom Well I could not figure out from the question that it isn''t part of data variable. v-if will be able to access one of data variable, computed property, method. It will not be aware of other variables.
Sorry I should have been more clear in the question. So what you reckon as appropriate solution in this circumstances?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.