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', []);
ngModule.directive('ngIscroll', function() {
ngModule.directive('ngIscroll', function($timeout) {
return {
link: function(scope, elm) {
setTimeout(function() {
$timeout(function() {
var myScroll;
// activate iscroll
myScroll = new IScroll(elm[0], {
mouseWheel: true
});
}, 0);
});
}
};

View File

@ -167,11 +167,21 @@ define(function(require) {
};
});
ngModule.directive('focusMe', function($timeout) {
ngModule.directive('focusMe', function($timeout, $parse) {
return {
link: function(scope, element) {
$timeout(function() {
element[0].focus();
//scope: true, // optionally create a child scope
link: function(scope, element, attrs) {
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">
<p>
<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>
<span>Cc:</span>