try to fix focus

This commit is contained in:
Tankred Hase 2013-10-19 15:06:23 +02:00
parent f3b4140f81
commit 88f3fe567c
3 changed files with 18 additions and 8 deletions

View File

@ -214,16 +214,16 @@ define(function(require) {
// //
var ngModule = angular.module('mail-list', []); var ngModule = angular.module('mail-list', []);
ngModule.directive('ngIscroll', function() { ngModule.directive('ngIscroll', function($timeout) {
return { return {
link: function(scope, elm) { link: function(scope, elm) {
setTimeout(function() { $timeout(function() {
var myScroll; var myScroll;
// activate iscroll // activate iscroll
myScroll = new IScroll(elm[0], { myScroll = new IScroll(elm[0], {
mouseWheel: true mouseWheel: true
}); });
}, 0); });
} }
}; };

View File

@ -167,11 +167,21 @@ define(function(require) {
}; };
}); });
ngModule.directive('focusMe', function($timeout) { ngModule.directive('focusMe', function($timeout, $parse) {
return { return {
link: function(scope, element) { //scope: true, // optionally create a child scope
$timeout(function() { link: function(scope, element, attrs) {
element[0].focus(); var model = $parse(attrs.focusMe);
scope.$watch(model, function(value) {
if (value === true) {
$timeout(function() {
element[0].focus();
});
}
});
// set attribute value to 'false' on blur event:
element.bind('blur', function() {
scope.$apply(model.assign(scope, false));
}); });
} }
}; };

View File

@ -9,7 +9,7 @@
<div class="headers"> <div class="headers">
<p> <p>
<span>To:</span> <span>To:</span>
<input type="email" ng-model="to" class="address-input" tabindex="1" focus-me> <input type="email" ng-model="to" class="address-input" tabindex="1" focus-me="writerOpen">
</p> </p>
<p> <p>
<span>Cc:</span> <span>Cc:</span>