2016-12-07 13 views
0

나는 몇 시간 동안 CLEditor를 사용하여 간단한 추가 작업을 수행했습니다. target = "_ blank"옵션을 추가 할 수 있습니다. 코드는 이것이다 :CLEditor - target = "_ blank"를 추가하십시오.

if (url != "") { 


    if ($("#blank").is(':checked')) { 


    editor.doc.execCommand("insertHTML", false, '<a href="' + url + '" target="_blank">' + selectedText(editor) + '</a>'); 

    } else { 

    execCommand(editor, data.command, url, null, data.button); 

    } 

    // Reset the text, hide the popup and set focus 
    $text.val("http://"); 
    hidePopups(); 
    focus(editor); 

} 

가 아니라 저장 한 이상한 결함을 작품 - 내가 = "_ 빈"목표 링크 후 편집 가능한 영역을 클릭해야 저장 할 수 있도록 추가됩니다. 새로 추가 된 링크가 DOM에 있지만 볼 수 있습니다. 영역을 클릭하지 않으면 (아무 데나) - 저장할 수 없습니다.

execCommand (editor, data.command, url, null, data.button)에 target = "_ blank"가없는 링크가 삽입되는 동안 execCommand ("insertHTML"..)를 추가합니다. 그런 문제는 없습니다.

이러한 문제의 원인은 무엇입니까? PHP 부분없이

모든 일 : 적절한 답변으로 어쨌든 간주 될 수 없다 https://jsfiddle.net/rzj0f334/

답변

0

이상한 해결. 그렇게 할 수있는 최선의 방법 확실히

if ($("#blank").is(':checked')) { 

    editor.doc.execCommand("insertHTML", false, '<a href="' + url + '" target="_blank">' + selectedText(editor) + '</a>'); 

    // copy all the editor's iframe HTML and send it to textarea (queer solution but that's all I was able to come up with) 
    var iframe_content = $('#666').contents().find("body").html(); 
    $('#input').html(iframe_content); 

    } else { 

    execCommand(editor, data.command, url, null, data.button); 

    } 

하지하지만 최소한 작동 : 내가 한 일은 이것이다. 그래도 더 나은 해결 방법을 찾아 주셔서 감사합니다.