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
14
votes
2 answers

Initialize Knockout observable from element attribute value

I have an element that possesses an attribute whose value is bound to a knockout observable: When the element loads I'd like the observable to contain the value…
KodeKreachor
  • 8,852
  • 10
  • 47
  • 64
14
votes
2 answers

Knockout is not evaluating an expression when using $index in a binding

Why is it, that when I try to use knockout.js to bind some text using $index, I get the code of a function instead of a number?
rboarman
  • 8,248
  • 8
  • 57
  • 87
13
votes
3 answers

Formatting Date in Knockout Template

I'm wanting to format a date in knockout's template. The date is currently being returned as 2013-07-04T00:00:00 I would like it to be displayed like 07/04/2013 Here is the binding I'm using Are their default…
rross
  • 2,236
  • 11
  • 36
  • 41
13
votes
1 answer

Click on checkbox in rows fires event bind on row knockout binding

I have a scenario where the Click event is bind to and checked value is bind to checkbox inside the . Now the problem is When the row is clicked the event is fired thats fine . But in case of I click the checkbox the observable…
Joy
  • 6,438
  • 8
  • 44
  • 75
12
votes
3 answers

Update Knockout.js Observable from JSON

I'm attempt to establish a grid and update it with more records via JSON. In this simple example I am able to achieve the required functionality but I can only update / push one JSON record. I would like to be able to add multiple records via JSON?…
Sparkle
  • 2,459
  • 3
  • 18
  • 20
12
votes
2 answers

Knockout.js using `value:` binding in a `foreach` over a list of strings - does not update

Here is a jsFiddle demonstrating the following problem: Given a foreach binding over a list of (observable) strings, the observables do not seem to update from changes to input tags bound inside the foreach. One would expect them to. Here's the…
Brian M. Hunt
  • 81,008
  • 74
  • 230
  • 343
12
votes
2 answers

How could I implement a fuzzy time date replacer using Knockout?

I'd like to implement what this plugin does using jQuery: https://github.com/rmm5t/jquery-timeago A short description of that plugin: This will turn all abbr elements with a class of timeago and an ISO 8601 timestamp in the title (conforming to the…
rball
  • 6,925
  • 7
  • 49
  • 77
12
votes
2 answers

Headless knockout viewmodel testing with mocha

I am trying to do headless testing of my knockout viewmodels. I purposely avoid dealing with any ui constructs in my viewmodel and leave the wireup to the html page. This works great in Jasmine since it runs in the browser, but when I switch to…
S. Hebert
  • 808
  • 1
  • 8
  • 18
11
votes
3 answers

How to do Knockout observable objects inside observable array

I want to implement an observable array and inside that array there should be observable objects (JS object). And In the view I'm iterating this array and getting the object and show the object properties. Let say there is a object like…
Chamith Malinda
  • 4,399
  • 5
  • 24
  • 28
11
votes
1 answer

How to bind to right mousebutton click in knockoutJs?

I just can't get knockout to bind to the right mousebutton click with the event binding. Mouseover etc. are working fine. Any suggestions? Thanks Andreas
nttakr
  • 1,637
  • 15
  • 25
10
votes
3 answers

Knockout validation: Dynamic constraints

I'm using Durandal, which in turn leverages off of Knockout. I want to be able to Change validation lengths dynamically Fiddle The fiddle seems to be behaving slightly different than my "working" solution, but its still not doing what I'm…
Rohan Büchner
  • 5,333
  • 4
  • 62
  • 106
10
votes
3 answers

Knockout 'for' binding?

Original Question Does any one have or know of a binding for knockout that would allow behavior similar to a for loop? I can make a foreach do what I want but it would be nice if I didn't have to do it that way. Edit 2 I am trying to create table…
Zholen
  • 1,762
  • 2
  • 24
  • 53
10
votes
5 answers

How to build a textarea with character counter and max length?

Please consider this jsfiddle. It contains something along these lines:

qinking126
  • 11,385
  • 25
  • 74
  • 124
10
votes
1 answer

Using attr binding in Knockout with a boolean value

I am trying to create a hidden form field from a boolean value in my viewModel.
rboarman
  • 8,248
  • 8
  • 57
  • 87
9
votes
2 answers

knockout unable to process binding "foreach"

I'm new to Knockout and I'm building an app that's effectively a large-scale calculator. So far I have two instances of knockout running on one page. One instance is working perfectly fine, however the other one is entirely broken and just won't…
leaksterrr
  • 3,800
  • 7
  • 34
  • 65
1 2
3
67 68