[英]Angular X-editable set focus event
I'm using angular-xeditable api.Could you tell me how to setfocus into a control when form 'loads' and press 'add row' button ? 我正在使用angular-xeditable api。你可以告诉我如何在表单'加载'时将setfocus设置到控件中并按下'add row'按钮吗?
There is a method named $activate(name)
on the above api.But I don't know how to use it with the above scenarios.Thanks. 在上面的api上有一个名为
$activate(name)
。但是我不知道如何在上面的场景中使用它。谢谢。
// add user
$scope.addUser = function() {
$scope.users.push({
id: $scope.users.length+1,
name: '',
status: null,
group: null,
isNew: true
});
};
Here is a fiddle with what I came up with to fix your problem. 这里是一个小提琴与我想出了解决您的问题。
I added a setFocus function call in the addUser method 我在addUser方法中添加了一个setFocus函数调用
$timeout( function() {
$scope.setFocus('name', $scope.users.length - 1);
}, 50);
$scope.setFocus = function (id, index) {
angular.element( document.querySelectorAll("#" + id))[index].focus();
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.