Questions tagged [knockout-3.0]

Knockout.js is an open source JavaScript library for dynamic HTML UIs using the Model-View-View Model (MVVM) pattern. Version 3.0 was released on October 25th, 2013.

Knockout.js is an implementation of the Model-View-View Model (MVVM) UI pattern. This tag is for questions specific to the 3.0 versions. Refer to the main tag for general information.

Version 3.0 Features

Among its more interesting new features:

  • Array change subscriptions – a super-fast way to find out how an observable array has changed (i.e., which items were just added/deleted/moved) without having to run any differencing algorithm. See the example later.
  • Binding to detached nodes so frameworks built on top of Knockout have an easier time organizing all the DOM fragments they work with in the background.
  • Clearer error reporting if binding hits a problem. After all, nobody enjoys debugging…
  • More helpful handling of arrays in which each entry is an observable (as distinct from observable arrays, which have of course always worked nicely).
  • Performance improvements
    • Computed properties no longer issue change notifications by default if their computed value is definitely unchanged since last time.
    • Reduced by almost half the number of hidden, internal observables that Knockout constructs to manage the state of your bindings.
    • Reduced the stack depth when processing chained observable notifications by four call frames per observable, permitting much longer chains.
  • Bug fixes including HTML-encoding dropdown-list captions, and reinstating the .toJSON function on the output from ko.toJS (which was inadvertently omitted in KO v3 beta).
  • New build system based on Grunt.js to make contributing to Knockout easier. At last all the custom Bash scripts are gone :)

More Details

For more information about the 3.0 release refer to:

407 questions
4
votes
2 answers

How to return an item from an observable array by property

I have this code: var id = event.target.getAttribute('id'); var matchedItem = ko.utils.arrayForEach(self.ProductEffectImagesToMatch(), function(item) { if (item.index == id) { return item; } } ); I want to get the item by index…
Laziale
  • 7,965
  • 46
  • 146
  • 262
4
votes
2 answers

How to iterate an Knockout ObservableArray? (length 0)

I'm new to knockout.js (and this is also my first stackoverflow post) and I'm now facing the following problem. I'm not able to bind the data from web api to a ko.observablearray. Why is the length of this Announcements ko.observablearray always 0?…
4
votes
1 answer

knockout binding handler - undefined bindingContext.$data on IE9

I am trying to create a custom binding handler to apply a role based access to fields on page. In custom handler it will check values of other observables from viewModel and based on condition it will enable or disable input control. But I am not…
4
votes
1 answer

Sorting an observableArray messes up the "checked" binding

I have a viewmodel with an observable array of child viewmodels. These should be user-sortable, so I'm using the sort() method of the observableArray: function ViewModel() { this.items = ko.observableArray([/* ... some items ... */]); …
Tomalak
  • 332,285
  • 67
  • 532
  • 628
4
votes
1 answer

Update observable from the custom components in knockout 3.2

I am trying to use custom components from knockout 3.2 and update the observable from within the component. Here is an example of my custom component: ko.components.register('voting', { viewModel: function(params) { var self =…
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
4
votes
1 answer

Unable to pass variables with custom components in knockout 3.2

I am trying to move forward with custom components in knockout 3.2. Everything works nice if I am using predefined parameters. For example is this jsFiddle. But when I pass parameters from my view model (I have read how to do it here) I am not…
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
4
votes
1 answer

Is it possible to create a custom component loader to inject components synchronously?

I've noticed some "choppy-ness" when loading a component for the first time, especially when it's at the top of the page (as everything underneath it has already rendered). Come to find in the Knockout Documentation that the component loaders supply…
4
votes
1 answer

Two way custom binding with knockut 3 and es5 plugin

In my custom binding, I cannot write data back to model. The problem is that there is no way to write into "writable" property. In knockout 2 there was possibility to use allBindingsAccessor()._ko_property_writers But in version 3 there are no such…
user133408
4
votes
2 answers

Typeahead.js not working in Knockout 3 foreach binding

I updated a web app to Bootstrap 3 and Knockout 3 and consequently lost the built in typeahead that was in Bootstrap 2. I added typeahead.js and it works great unless I have a typeahead within a Knockout 'foreach' binding. I included code that…
RickM
  • 43
  • 1
  • 4
4
votes
2 answers

JavaScript Runtime error 'ko' is undefined

I am new to KnockOut js.When I tried a simple Hello World Example in Visual Studio 2012 ,I am getting an runtime exception saying "Javascript Run time error:ko is undefined".Please help me this is my code
Rashad Valliyengal
  • 3,132
  • 1
  • 25
  • 39
4
votes
2 answers

Custom binding no longer working in KnockoutJS 3.0

All of the sudden, the following code no longer works when targeting KnockoutJS 3.0. How can I work around this? JavaScript: ko.bindingHandlers.limitCharacters = { update: function(element, valueAccessor, allBindingsAccessor, viewModel) { …
Brian David Berman
  • 7,514
  • 26
  • 77
  • 144
3
votes
3 answers

Why does knockout template binding stop working after manually reordering - and reverting - dom items?

I am using a knockout foreach (more specifically, template: { foreach: items }) binding to display a list of elements. I then proceed to take the following actions: Swap the first and second elements of the observable array. I see the changes…
3
votes
1 answer

How to find all the subscriptions functions from an observable while debugging

I am debugging through my knockout application. While debugging I change some observable value like data.myObservable(true); where data is passed to my function. At this point when I analyze the variable using the scope in developer console I see…
Jerin Joseph
  • 759
  • 1
  • 7
  • 22
3
votes
3 answers

Computed stops triggering forever if dependency is inside of false branch statement

I'm faced a problem that my computed observable stops triggering after some sequence of dependency changes. Finally I found out the point: if dependency was inside of false branch statement during latest evaluation, computed will not be triggered…
shameleo
  • 344
  • 2
  • 13
3
votes
0 answers

Gridstack not updating height properly inside iframe

Here I'm using an iframe to display a page-in-page that contains a Gridstack grid-based editor to reposition its elements. The inner page should consist of plain HTML and CSS. All gridstack-related CSS and any ko-related JS calls should be made from…
Peter G.
  • 7,816
  • 20
  • 80
  • 154
1
2
3
27 28