Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your code <em>logically</em> fine, your problem is in mis-use of <code>this</code> inside the <code>capitalizeLastName</code> function.</p> <p>In your case <code>this</code> keyword refers to the object the function belongs to, or the <code>window</code> object if the function belongs to no object but not your View-Model object. That's why in most KnockoutJS examples we use <code>var self=this;</code> at the first line of View-Model definition to obtain a refrence to the View-Model object.</p> <p><a href="http://jsfiddle.net/5WXvF/" rel="nofollow noreferrer">Updated working demo based on your code</a></p> <p>Check the following SO questions for better undertanding:</p> <ol> <li><a href="https://stackoverflow.com/questions/15956898/in-knockout-js-why-this-is-being-assigned-to-self">In knockout.js, why “this” is being assigned to “self”?</a></li> <li><a href="https://stackoverflow.com/questions/1963357/this-inside-function">this inside function</a></li> </ol> <p><strong><em>Update</em></strong></p> <p>In order to update your view <strong><em>while writing</em></strong> firstname/lastname textbox, you need just to add <code>valueUpdate: 'afterkeydown'</code> to your binding.</p> <p>From <a href="http://knockoutjs.com/documentation/value-binding.html#parameters" rel="nofollow noreferrer">KnockoutJS documentation</a>:</p> <blockquote> <p>valueUpdate</p> <p>If your binding also includes a parameter called valueUpdate, this defines additional browser events KO should use to detect changes besides the change event. The following string values are the most commonly useful choices:</p> <p>"afterkeydown" - updates your view model as soon as the user begins typing a character. This works by catching the browser’s keydown event and handling the event asynchronously.</p> </blockquote> <p><a href="http://jsfiddle.net/5WXvF/1/" rel="nofollow noreferrer">Updated Demo</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload