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

  • Home
  • SEARCH
  • 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 8248385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:10:29+00:00 2026-06-07T23:10:29+00:00

I have a simple collection bound to an observableArray that is initially empty. When

  • 0

I have a simple collection bound to an observableArray that is initially empty. When the page renders it ‘sometimes’ will show the empty template before the binding kicks in and removes the element. If you can’t see it refresh the page a few times. This is happening as below with the container less templates but also happens with normal inline and script tag style templates.

View:

<div>
  <input data-bind="value: address"/>
  <button data-bind="click: search">Search</button>
</div>
<!-- ko if: list().length > 0 -->
<h5 data-bind="text: list().length"></h5>
<!-- /ko -->
<!-- ko foreach: list -->
    <div class="result" data-bind="text: addr"></div>
<!-- /ko -->​

Javascript:

$(function() {

  var viewModel = function() {
      var self = this;

      self.address = ko.observable("Portland");

      self.list = ko.observableArray();
      self.hasData = function(){return self.list().length > 0;};

      self.search = function() {
              self.list.push({ addr: "Item01" , index: 1 });
              self.list.push({ addr: "Item02" , index: 2 });
              self.list.push({ addr: "Item03" , index: 3 });      
      };
  };

  var vm = new viewModel();
  ko.applyBindings(vm);
});​

I doesn’t seem to happen to much on jsFiddle – http://jsfiddle.net/motowilliams/mx7SM/ or JSBin but does happen locally and when deployed – http://knockouttest.herokuapp.com/.

Any ideas?

  • 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-07T23:10:30+00:00Added an answer on June 7, 2026 at 11:10 pm

    I am not able to see the issue in your sample, but a couple choices that you have are:

    • use a named template in a script tag. Browsers won’t render markup that is in the script tag. You did seem to indicate that you tried it, but you might want to give it another look.

    • otherwise, you can wrap it in an element and set display: none on it and use data-bind="visible: true" as well. When the page loads it will be hidden and KO will set it to visible when the binding is happening. Something like:

    Here is a sample with the original and the two options that I mentioned and a two second delay in applying the bindings: http://jsfiddle.net/rniemeyer/mx7SM/2/

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

Sidebar

Related Questions

I have a simple LINQ query that is going against a collection. Dim oList
Say I have a ListBox that is bound to an observable collection on my
I have a simple ListView bound to a collection of Calculations. The view calls
I have a listview control that is bound to an observable collection that I
We have a data grid on a window that is bound to a collection
I have simple MongoDB collection and I am using SLIM micro-framework to develop a
I have a class CollectionOfThings . As its name suggests its a simple collection
I have a simple json string which contains a collection of objects http://sandapps.com/InAppAds/ads.json.txt When
I have a simple datagrid to which I am binding a collection using ItemsSource.
I have an observable collection bound to a listbox in WPF. One of the

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.