Questions tagged [knockout-2.0]

Knockout.js is an open source JavaScript library for dynamic HTML UIs using the Model-View-View Model (MVVM) pattern. This tag is for questions specific to the 2.0 releases.

Knockout.js is an open source JavaScript implementation of the Model-View-ViewModel (MVVM) UI pattern. This tag is for version 2.0 specific questions. See also the main tag for general information about Knockout.js.

Version 2.0 of Knockout.js as announced by its creator included the following new features:

  1. Control flow bindings such as if, ifnot, with, and foreach;
  2. Containerless control flow, e.g. <!-- ko foreach: products -->;
  3. Access to parent binding contexts through contextual variables such as $parent;
  4. Cleaner event handling using the click binding;
  5. Binding providers (and hence external bindings)
  6. Throttling by extending observables.

Find the v2.0.0 source on GitHub.

1009 questions
9
votes
1 answer

knockout validation error message span

I am using knockout validation plugin and its working fine but i have a little problem , I want to make the validation span a little but more prominent by using css , and i only want to insert the validation span just before the input element ,…
Ancient
  • 3,007
  • 14
  • 55
  • 104
9
votes
2 answers

Mapping hierarchical JSON to TypeScript-KnockoutJS typed Object

Let's start with a thanks in advance :) OK, So I'm trying to load/map hierarchical TypeScript/KnockoutJS typed classes from matching JSON data using the knockout.mapping plugin, the hierarchy can be to the Nth degree. I know I can do the following…
9
votes
2 answers

is ko.applyBindings synchronous or asynchronous?

Does the generated view exists right after you call ko.applyBindings() or does the scaffolding happen asynchronously? Thanks!
vtortola
  • 34,709
  • 29
  • 161
  • 263
9
votes
3 answers

knockoutjs click binding not working in nested foreach

So i have a really weird problem with a knockoutjs click binding not getting attached to anchor tags. Other data-bind="" works but not the click binding. Below you can see the HTML and part of the viewmodel js file var tag = function (data) { …
Kimpo
  • 5,835
  • 4
  • 26
  • 30
8
votes
1 answer

Knockout bindingHandler for comma separated numbers

I'm building a very number-heavy app in KnockoutJS and I want to have the ability to format large numbers so that they're comma-seperated and nice on the eye (xxx,xxx). As you'll see from the fiddle below, I do have this working by wrapping the…
leaksterrr
  • 3,800
  • 7
  • 34
  • 65
8
votes
1 answer

Customize error message and placement

Currently the Knockout-Validation plugin automatically add this HTML element to my web page: This field is required. I want to change the "This field is required." text. I want to change the placement of the…
Mr.Wang from Next Door
  • 13,670
  • 12
  • 64
  • 97
8
votes
3 answers

How to use a one way binding in knockout

I have a viewModel like this: var viewModel = { firstName: 'Fred' } and a text box bound to it like this I was under the impression that this would set up a one way binding as the…
nixon
  • 1,952
  • 5
  • 21
  • 41
8
votes
1 answer

Does the simpleGrid require additional downloads?

I want to try the simpleGrid in a HotTowel project. When it came to: this.gridViewModel = new ko.simpleGrid.viewModel({ data: this.items, .... it threw an exception: Unable to get property 'viewModel' of undefined or null reference` I…
Old Geezer
  • 14,854
  • 31
  • 111
  • 198
8
votes
2 answers

Knockout.js input focus after click

I am trying to set focus on an input with knockout after the click event is fired but couldn't find a clean way to handle it without coupling with the DOM. Here is the JS code I have: (function() { var vm = { text: ko.observable(), …
tugberk
  • 57,477
  • 67
  • 243
  • 335
8
votes
2 answers

Knockout fires change event when select list initializing

I'm having a issue with knockout select list binding, My problem is I'm having a list of items, that contains description,key and editable. using the list of items I'm populating the select box. var RequiredItemLine = function () { var…
Arooran
  • 637
  • 1
  • 17
  • 31
8
votes
1 answer

knockout js 'with' binding, hide if array is empty

I have a category drop down list which controls a sub category drop down list. I want to hide the sub categories drop down list if the sub category array is empty for the selected category. Sample code below: