0

我有一个无法将光标放入的可编辑文本框,可能是因为当我单击以移动光标或选择文本块时,框架 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' );
}
4

1 回答 1

0

哦.. 错字,我在销毁方法上使用了 curobj 而不是 curObj ......它现在可以工作了。除了 setEndOfContenteditable 不起作用,但这是一个不同的问题。

于 2013-10-02T12:44:20.007 回答