1
'If'바인딩이 적용된 폼과 그 안에 입력 컨트롤이 있습니다. 그래서이 유사하게 나타납니다'If'바인딩 표현식이 참이 될 때 기본 포커스를 설정합니다.
<form data-bind="if: MyExpression">
<input id="input1" class="autofocus"></input>
<input id="input2"></input>
<input id="input3"></input>
</form>
을 이제 'MyExpression이'진정한 켜 양식을 화면에 표시 할 때마다 나는 '자동 초점'클래스 입력에 포커스를 설정합니다. 아이디어를 얻는 방법은 무엇입니까?
는 지금까지이 시도 :this.MyExpression.subscribe(function (isTrue) {
if (isTrue) {
$('.autofocus').focus();
}
});
하지만, 작동하지 않았다.
도움 주셔서 감사합니다.
매력처럼 작동합니다. 감사. –