question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem when using the package with Vue

See original GitHub issue

Hey guys. I’m facing an issue when trying to use this plugin within a Vue component. Here’s my code:

<ul data-simplebar class="conversation-list">
                        <div v-for="message in conversation.messages" v-bind:key="message.id">
                            <li class="clearfix" @if="message.fk_sender == curr_contact">
                                <div class="chat-avatar">
                                    <img :src="activeContact.photo_url" :alt="activeContact.firt_name">
                                    <i>{{ message.created_at }}</i>
                                </div>
                                <div class="conversation-text">
                                    <div class="ctext-wrap">
                                        <i>{{ activeContact.first_name }}</i>
                                        <p>
                                            {{ message.message }}
                                        </p>
                                    </div>
                                </div>
                            </li>
                            <li class="clearfix odd" @if="message.fk_sender != curr_contact">
                                <div class="chat-avatar">
                                    <img src="/images/female_avatar.png" alt="Female">
                                    <i>10:01</i>
                                </div>
                                <div class="conversation-text">
                                    <div class="ctext-wrap">
                                        <i>Smith</i>
                                        <p>
                                            Hi, How are you? What about our next meeting?
                                        </p>
                                    </div>
                                </div>
                            </li>
                        </div>
                    </ul>

When I put static content inside the

    , the bar works just fine. The problem is when I add the dynamic content, as shown. Then, the divs generated by the loop are placed outside the div.simplebar-content created by the simplebar plugin. I’m using on a browser with enabled js. Can someone help me with this? I don’t know if I’m doing something wrong, since the documentation says that the plugin should take care of dynamic content, except for older browsers…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
Grsmtocommented, May 3, 2018

Is you content loaded asynchronously? Like from a server? The problem if it’s the case is that SimpleBar must be initialised only after your content has been set. And any further content needs to be added using the getContentElement() function.

I think you can try to do this way by pre-defining the required DOM directly:

<ul data-simplebar class="conversation-list">
    <div class="simplebar-scroll-content">
        <div class="simplebar-content">
            <div v-for="message in conversation.messages" v-bind:key="message.id">
                ...
            </div>
        </div>
    </div>
</ul>

It’s not ideal but I’m currently working on a new version of the plugin to improve compatibility with frameworks like Vue, React, Angular…Also will think about adding examples to make it simple to implement!

Let me know if that works. Thanks.

1reaction
waxapicommented, Jan 24, 2019

Is you content loaded asynchronously? Like from a server? The problem if it’s the case is that SimpleBar must be initialised only after your content has been set. And any further content needs to be added using the getContentElement() function.

I think you can try to do this way by pre-defining the required DOM directly:

<ul data-simplebar class="conversation-list">
    <div class="simplebar-scroll-content">
        <div class="simplebar-content">
            <div v-for="message in conversation.messages" v-bind:key="message.id">
                ...
            </div>
        </div>
    </div>
</ul>

It’s not ideal but I’m currently working on a new version of the plugin to improve compatibility with frameworks like Vue, React, Angular…Also will think about adding examples to make it simple to implement!

Let me know if that works. Thanks.

Simplebar was broken for me when using Vue and adding data to a list dynamically.

I fixed by doing this. Thanks for the help @Grsmto

<div class="messages" data-simplebar>
   <div class="simplebar-wrapper" style="margin: -10px;">
      <div class="simplebar-height-auto-observer-wrapper">
         <div class="simplebar-height-auto-observer"></div>
      </div>
      <div class="simplebar-mask">
         <div class="simplebar-offset" style="right: 0px; bottom: 0px;">
            <div class="simplebar-content" style="padding: 10px; height: 100%; overflow: hidden;">
               <div class="msg" v-for="(msg, index) in messages" :key="index">
                  <img :src="msg.avatar" width="75" sizes="35px" class="avatar" />
                  <div class="wrapper">
                     <div class="info">
                        <div class="name">{{ msg.username }}</div>
                        <div class="lvl">{{ msg.lvl }}</div>
                     </div>
                     <div class="message">{{ msg.message }}</div>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
   <div class="simplebar-placeholder" style="width: 303px; height: 361px;"></div>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I fix a "Vue packages version mismatch" error on ...
If you use vue one version and vue-template-compiler another version, that's a problem. Run this command npm update vue-template-compiler.
Read more >
Common mistakes to avoid while working with Vue.js
My first issue was a pretty basic one. The first thing to do in order to use Vue.js is to import it. If...
Read more >
vue cli fails to get packages when npm is using a custom ...
In the case of vue ui the current package version and details on the latest version should be displayed. What is actually happening?...
Read more >
Vue.js Site Deployment Error - node package problem?
Hi, I'm new to web dev and I've been trying to create and deploy a starter portfolio page in vue.js. The project works...
Read more >
The Pros and Cons of Vue.js - AltexSoft
Now we are going to talk about using Vue, and what it has to offer as a tool. The Pros of Vue.js. As...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found