我有一个无法将光标放入的可编辑文本框,可能是因为当我单击以移动光标或选择文本块时,框架 DIV 正在捕获单击。我认为可拖动与它有关,尽管不确定。
非常感谢任何输入。
这是我的代码(“curObj”是框架,“inner”是我设置为可编辑的 div)。
function textbox_editable() {
var curObj = window.curObj;
var inner = '#' + $(curObj).attr("id") + ' .object_inner';
//unless the doubleclick was in a textbox that is already activated for editability...
if ( $(inner).attr('contentEditable') != 'true' ) {
$(inner).attr('contentEditable',true); //set attribute editable
$(curobj).draggable( "destroy" );//remove draggable (it blocks the click-to-move-cursor functionality
$(curobj).resizable( "destroy" );//remove resizable (it blocks the click-to-move-cursor functionality
//make cursor text
$(inner).css( "cursor", 'text' );
setEndOfContenteditable(inner)
}
}
//called when we are done editing the contents of a textbox
function textbox_uneditable() {
$( ".object_textbox .object_inner" ).removeAttr('contentEditable'); //remove editable attribute if it was present
$( ".object_textbox" ).draggable(); //reinstate draggable
$( ".object_textbox" ).resizable(); //reinstate draggable
//restore cursor
$( ".object_textbox" ).css( "cursor", 'move' );
}