genannt wird, habe ich eine Vorlage, die in docs hasFocus
ähnlich dem Beispiel verwendet: http://knockoutjs.com/documentation/hasfocus-binding.htmlKnockout JS `hasFocus` innerhalb Vorlage, die zweimal
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>field test</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css">
<style>
body {
margin-top: 1em;
}
</style>
<script src="https://cdn.jsdelivr.net/g/[email protected],[email protected],[email protected]"></script>
<script>
$(function() {
var VM = function() {
var model = {};
model = {
one: ko.observable(false),
two: ko.observable(false)
};
this.model = model;
};
ko.applyBindings(new VM());
});
</script>
</head>
<body>
<script type="text/template" id="first-template">
<input type="text" class='form-control' data-bind="hasFocus: model.one">
<p>one has<span data-bind="visible: !model.one()"> not got</span> focus now</p>
<input type="text" class='form-control' data-bind="hasFocus: model.two">
<p>two has<span data-bind="visible: !model.two()"> not got</span> focus now</p>
</script>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div data-bind="template: { name: 'first-template' }"></div>
<!-- if I uncomment the next line, it stops working... -->
<!-- <div data-bind="template: { name: 'first-template' }"></div> -->
</div>
</div>
</div>
</body>
</html>
alles funktioniert wie erwartet, auf dem Modell den Fokus Zustandsaktualisierungs richtig beim Betreten und Verlassen des Feldes. Wenn ich die Vorlage jedoch ein zweites Mal anwende, scheint die Vorlage mit Ausnahme des Fokusstatus in Ordnung zu sein. Wird dies nicht unterstützt, oder führe ich etwas falsch um? Wie kann ich die Vorlage mehrmals verwenden und weiterhin den Fokusstatus verwenden?