Skip to content

Commit

Permalink
Merge pull request vitalets#251 from enapupe/move
Browse files Browse the repository at this point in the history
added setTimeout() to call $hide on another stack
  • Loading branch information
victorarbuesmallada committed Mar 19, 2015
2 parents 4f2f989 + b596ba9 commit a085d79
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/js/editable-element/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,19 @@ angular.module('xeditable').factory('editableController',
}
};

self.activate = function() {
self.activate = function(start, end) {
setTimeout(function() {
var el = self.inputEl[0];
if (editableOptions.activate === 'focus' && el.focus) {
if(start){
end = end || start;
el.onfocus = function(){
var that = this;
setTimeout(function(){
that.setSelectionRange(start,end);
});
};
}
el.focus();
}
if (editableOptions.activate === 'select' && el.select) {
Expand Down
7 changes: 5 additions & 2 deletions src/js/editable-form/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ angular.module('xeditable').factory('editableFormController',
}

//by default activate first field
this.$editables[0].activate();
this.$editables[0].activate(this.$editables[0].elem[0].selectionStart, this.$editables[0].elem[0].selectionEnd);
}
},

Expand Down Expand Up @@ -194,7 +194,10 @@ angular.module('xeditable').factory('editableFormController',
editable.cancel();
});
// self hide
this.$hide();
var that = this;
setTimeout(function(){
that.$hide();
});
},

$setWaiting: function(value) {
Expand Down

0 comments on commit a085d79

Please sign in to comment.