2013-10-02 19 views
0

我有一個不能放置光標的可編輯文本框,可能是因爲當我單擊移動光標或選擇文本塊時,構圖DIV正在捕捉點擊。我認爲可拖動的東西與它有關,儘管不確定。如何讓我的點擊達到inner(contentEditable)div?

任何輸入,非常感謝。

這裏是我的代碼(「curObj」是框架,「內部」是我設置可編輯的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'); 
} 
+0

如果設置爲true/false,則應該使用prop()而不是attr – Anton

回答

0

哦..錯字,我有curobj上的摧毀方法,而不是curObj ...現在的作品。除了setEndOfContenteditable不起作用,但這是一個不同的問題。