0

I have a page which has some KO scripts within it, now at the moment my 2 drop-downs which do not have knockout are loading before the KO scripts meaning it looks really ugly, is there a way i can make everything wait until everything is ready to show and then show?

Thanks any advice would be great?

Pete Tong
  • 51
  • 1
  • 6

1 Answers1

1

Use container to which you apply bindings with 'display: none' style.

<div style='display: none' id='container' data-bind='visible: true'>
</div>

Then use visible binding on the root of the view model like:

function MyViewModel(){
  var self = this;
  ...
  self.Loaded = true;
  ...
}

ko.applyBindings(new MyViewModel(), document.getElementById('container'));

Update. As per @Jeroen's comment even this will serve:

<div style='display: none' id='container' data-bind='visible: true'>
</div>
Ivan
  • 769
  • 5
  • 17