diff --git a/source/Ox.UI/js/Form/EditableContent.js b/source/Ox.UI/js/Form/EditableContent.js index 2e1a7420..68bc3ad6 100644 --- a/source/Ox.UI/js/Form/EditableContent.js +++ b/source/Ox.UI/js/Form/EditableContent.js @@ -67,6 +67,7 @@ Ox.EditableContent = function(options, self) { self.$input.show().on({ focus: function() { self.editing = true; + updateSelection(); } }); setTimeout(function() { @@ -125,6 +126,19 @@ Ox.EditableContent = function(options, self) { self.$value.html(formatValue()).show(); that.triggerEvent('submit', {value: self.options.value}); } + function updateSelection() { + var range, selection; + selection = window.getSelection(); + selection.removeAllRanges(); + range = document.createRange(); + range.selectNodeContents(self.$input[0]); + selection.addRange(range); + if (self.options.type != 'span') { + setTimeout(function() { + selection.collapseToEnd(); + }, 0); + } + } that.css = function(css) { that.$element.css(css); @@ -135,4 +149,4 @@ Ox.EditableContent = function(options, self) { return that; -}; \ No newline at end of file +};