Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:41:51+00:00 2026-06-17T07:41:51+00:00

I’m trying to use jScrollPane with meteor.js, but it’s not behaving as expected. First

  • 0

I’m trying to use jScrollPane with meteor.js, but it’s not behaving as expected. First off, if I give the ‘.scroll-pane’ class to a div, it will work without being initialized explicitly by me. But when I try to initialize it explicitly, it does not work. Is this some sort of meteor magic? or I am missing something obvious.

Second, if I don’t initialize it, but I try to access it…it’s data is empty, so I can’t use the api on it. I’ve included some sample code below, please let me know if I am doing something wrong.

html

...
    <div class="rectangle">
      <div class="chat scroll-pane" id="chatWindow">

      {{#each Messages}}
      {{#if Compare uId UID}}
      <div class="bubble me">{{Text}}</div>
      {{else}}
      <div class="bubble you">{{Text}}</div>
      {{/if}}
      {{/each}} 
      </div>


      <input class="textinput" type="text" placeholder="Insert Message" id="textToSubmit">
      <button class="btn btn-success" id="submit" autofocus="autofocus">Send
        <br>
        <br>
      </button>
    </div>

js

    if (Meteor.isClient) {

    ...
    var Message = new Meteor.Collection("Message");

    Template.Message.rendered = function(){
      if(!this._rendered) {
        this._rendered = true;
        var scroll = $(this.find("#chatWindow"));
        var api = scroll.data('jsp');
        console.log(api);
      }
   };

   ...
    }

If you need any more info, please let me know.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:41:52+00:00Added an answer on June 17, 2026 at 7:41 am

    There are a couple things going on:

    (1) you need to wire up the reactivity to your template to ensure that the timing of the incoming Messages is correct. This is achieved by using a Session variable to set the load, and by setting Template.scroll.Messages equal to a function that returns a collection cursor. Typically, you would not need to set a Session this way if your Template.scroll.Messages returns a query that uses a Session object (i.e., a roomId). If that were the case, you could forgo the callback on the Meteor.subscribe call and the “loaded” Session altogether.

    (2) you’ll want to turn off autopublish (meteor remove autopublish) and explicitly subscribe to the data so you know when your collection loads;

    (3) you must declare your messages Collection outside the isClient block to ensure the server knows about it.

    HTML:

    <template name="scroll">
        <div class="rectangle">
            <div style="height:100px;overflow:auto;" id="chatWindow">
                {{#each Messages}}
                    {{#if isMe this}}
                        <div class="bubble me">{{text}}</div>
                    {{else}}
                        <div class="bubble you">{{text}}</div>
                    {{/if}}
                {{/each}} 
            </div>
        </div>
    </template>
    

    JS:

    Messages = new Meteor.Collection("messages");
    
    if (Meteor.isClient) {
        Meteor.subscribe("messages", function () {
            Session.set("loaded", true);
        });
    
        Template.scroll.rendered = function () {
            if (Session.get("loaded")) {
                $(this.find("#chatWindow")).jScrollPane();
                var api = $(this.find("#chatWindow")).data("jsp");
                ...
            }
        };
    
        Template.scroll.helpers({
            isMe: function (msg) {
                return msg.userName === 'me';
            }
        });
    
        Template.scroll.Messages = function () {
            return Messages.find({});
        };
    }
    
    if (Meteor.isServer) {
            Meteor.startup(function () {
            if (Messages.find().count() === 0) {
                Messages.insert({ text: 'Message 1', userName: 'me' });
                Messages.insert({ text: 'Message 2', userName: 'you' });
                Messages.insert({ text: 'Message 3', userName: 'me' });
            }
        });
        Meteor.publish("messages", function () { return Messages.find({}); });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am confused How to use looping for Json response Array in another Array.
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.