Wybierz () Pole wejściowe za pomocą Knockout.js

Jestem nowym użytkownikiem Knockout.js.

Co to jestNajlepiej sposób naselect() na<input /> kiedy stanie się widoczny?

Widok:

<p>
    Name: 
    <b data-bind="visible: !editing(), text: name, click: edit">&nbsp;</b>
    <input data-bind="visible: editing, value: name, hasfocus: editing" />
</p>

ViewModel:

function PersonViewModel(name) {
    // Data
    this.name = ko.observable(name);
    this.editing = ko.observable(false);

    // Behaviors
    this.edit = function() { this.editing(true) }
}

ko.applyBindings(new PersonViewModel("Bert Bertington"));

http://knockoutjs.com/documentation/hasfocus-binding.html

http://jsfiddle.net/RnCUd/

Dzięki!

questionAnswers(2)

yourAnswerToTheQuestion