国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

angular.js - How to automatically get focus after displaying textarea in angularjs
大家講道理
大家講道理 2017-05-15 17:06:42
0
1
700
<p ng-repeat="x in inputContent track by $index">
    <p ng-if="x.hint" ng-click="toEdit({{$index}})" class="lc-hint">{{x.placeholder}}</p>
    <textarea ng-if="!x.readable" ng-model="x.value"></textarea>
</p>

Multiple such structures are generated by ng-repeat. The textarea is hidden at first. Click lc-hint to make the textarea appear. How to automatically gain focus.

The setfocus command in the official documentation does not seem to work. Help

大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(1)
大家講道理

There is something wrong with your code:

ng-click="toEdit({{$index}})"

should be written as

ng-click="toEdit($index)"

Why not use the native one and add the id of textarea to abc;

document.getElementById("abc").focus();

If you input in the console, it is best to add a delay. The focus of textarea can only be triggered when the current page is in focus state. After typing, click anywhere on the page immediately to trigger:

setTimeout(function(){document.getElementById("abc").focus();},1000);

The setfocus you encounter does not take effect, it may be because the current page is not in focus.

Put it in your code environment, add textarea with id, the prefix I wrote is suibianla_{whatever}:

<textarea id="suibianla_{{ $index }}" ng-if="!x.readable" ng-model="x.value"></textarea>
$scope.toEdit = function(index){
    //你的業(yè)務代碼
    inputContent[index].readable = true;    //我猜你是這樣寫的,在這里后邊加一句
    document.getElementById("suibianla_" + index).focus();
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template