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 8353509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:17:06+00:00 2026-06-09T09:17:06+00:00

The setting I have Backbone.Marionette.ItemView which renders some content. When the content is rendered

  • 0

The setting

I have Backbone.Marionette.ItemView which renders some content. When the content is rendered I’d like to apply a jQuery plugin which turns part of the view into a container with a scrollbar.

The scrollbar is implemented completely in javascript and upon initialization it has to check the height of the scroll-container as well as that of the content inside the container.

If the content is higher then the container, a scrollbar should be enabled.

The problem

While this all sounds simple, I’ve ran into a strange problem:

If I initialize my scrollbar plugin directly in the onRender callback it seems to think the .scroll-container element has a height 0 and maxHeight of 0.

If I wrap the initialization code inside a 0ms timeout though, everything works as it should, the .scroll-container element’s height property is returned by jQuery correctly and the scrollbar plugin works great.

The code

onRender: function() {
  var that = this;
  setTimeout(function() {
    that.onLayout();
    var $scrollContainer = that.$el.find('.scroll-container'), 
        scrollPane = new ScrollPane($scrollContainer, {
          maxHeightProperty: 'maxHeight',
          scrollUpButton: false,
          scrollDownButton: false
        });
  }, 0);
},

The question

I’m assuming the problem occurs because the browser didn’t finish actually rendering the newly inserted html when the onRender callback is executed.

Is this assumption correct? And if so, is my solution of using a 0ms timeout reliable under normal circumstances?

  • 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-09T09:17:09+00:00Added an answer on June 9, 2026 at 9:17 am

    Since the plugin in question depends on the DOM, onRender won’t do what you need. This callback kicks off after the view has been rendered, but there is no guarantee that the view’s el has been added to the DOM yet. In fact, you are safe assuming the opposite – that it has not been added yet.

    If you’re using a Marionette Region to show the view, you can implement an onShow method in your view. This method gets called by the region, after the region has added the view to the DOM. It was implemented specifically to handle this situation.

    For a little more info on this, and on working with jQuery plugins in general, see this blog post: http://lostechies.com/derickbailey/2012/02/20/using-jquery-plugins-and-ui-controls-with-backbone/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to read custom setting which i have done in ServiceConfiguration.cscfg &
I have been looking at backbone.js/spine.js and I like the idea of just setting
I have a setting stored in database which has a value .jpg|.gif|.png . I
We have the following setting: There is a web application which has a jboss
I have noticed that when multiple attributes of a Backbone model are set like
I have a project which is heavily JavaScript based (e.g. node.js, backbone.js, etc.). I'm
I have a generic subclass of Backbone.View which has a close event listener. var
I have a setting in my .emacs like this (display-battery-mode 1) . It displays
I have setting up some sliders on 1 page but when you slide 1
Is it a bad practice to have backbone views which do not depend on

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.