Selecting Text in cell when editing text using the input Template
I'm using the template code below, but can not highlight the text in the text box when i'm trying to edit it. is there a better editable cell template or anyone know how to fix this one?
Thanks in advance.
Thanks in advance.
// ****************************************************************
// Input Cell Template.
// ****************************************************************
My.Templates.Input = Active.Templates.Text.subclass();
My.Templates.Input.create = function()
{
var obj = this.prototype;
// editor is not part of the template,
// there is only one single instance of editor object.
var editor = new Active.HTML.INPUT;
editor.setClass("templates", "input");
editor.setAttribute("type", "text");
editor.setAttribute("value", function(){
return template.getItemProperty("text");
});
// template variable provides temporary reference
// to the parent template during edit mode.
var template;
function switchToEditMode(){
if (template) {
switchToTextMode()
}
template = this;
template.element().style.padding = 0;
template.element().innerHTML = editor;
editor.element().focus();
editor.setEvent("ondblclick", editor.element().focus());
obj.setEvent("ondblclick", switchToTextMode);
editing=true;
}
obj.setEvent("ondblclick", switchToEditMode);
function switchToTextMode(){
var value = editor.element().value;
template.setItemProperty("text", value);
template.refresh();
template = null;
obj.setEvent("ondblclick", switchToEditMode);
editing=false;
}
function doNothing(){
editor.element().focus();
}
editor.setEvent("onblur", switchToTextMode);
};
David D
June 25,