【发布时间】:2014-11-11 21:40:13
【问题描述】:
当用户点击链接时,我正在使用指令触发输入字段的焦点。除了 IOS,它在任何地方都可以正常工作。它没有在焦点上打开 ios 设备(iphone/ipad)上的键盘。它在输入周围添加了蓝色边框,表明它正在聚焦。如何在焦点上打开 ios 设备中的键盘?
HTML
<a data-mya-triggerfocus="something" >Something</a>
<input name="something" id="something" />
JS
angular.module('app').directive('myaTriggerfocus', function ($timeout) {
return {
link: function (scope, element, attrs) {
element.bind('click', function () {
$timeout(function () {
var otherElement = document.querySelector('#' + attrs.myaTriggerfocus);
otherElement.focus();
});
});
}
};
});
【问题讨论】:
标签: jquery ios angularjs angularjs-directive