Question

I have an editable textbox that I can't place cursor in, probably because the framing DIV is catching the click when I click to move the cursor or select a block of text. I think the draggable has something to do with it, although not sure.

Any input is much appreciated.

Here is my code ("curObj" is the frame, "inner" is the div that I set editable on).

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' );
}
Était-ce utile?

La solution

Oh.. typo, I had curobj on the destroy-methods instead of curObj... it works now. Except the setEndOfContenteditable doesn't work but that's a different issue.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top