2016-06-21 2 views
1

yui TextAreaCellEditor에 문제가 있습니다.yui에서 htmlentities를 디코딩하는 방법 TextAreaCellEditor

아래 yui 문은 yui 열을 클릭하면 저장 및 취소 버튼으로 편집기를 엽니 다.

var myTextareaCellEditor = new YAHOO.widget.TextareaCellEditor(); 

var myColumnDefs = [ 
{key:"title",label:"Title", sortable:true ,editor: myTextareaCellEditor}, 
]; 

지금 내 문제는 지금까지 내가 제목을 지정하고 내 제목이 " text&data<new>"입니다 예를 들어 데이터베이스에 저장할 때입니다. 제목 텍스트가 포함 된 편집기를 열면 올바르게 저장됩니다. " text&amp;data&lt;new&gt;"과 같이 표시됩니다. 편집기에서 html 엔티티를 제거하고 싶습니다.

모든 도움을 주시면 대단히 감사하겠습니다.

답변

2

TextareaCellEditor 편집기가 initailized 초점 당신은 그것을 사용할 수있다, 초점 함수가 호출되고, 거기에있을 때, "초점"라는 이벤트가 있습니다.

var myTextareaCellEditor = new YAHOO.widget.TextareaCellEditor({ 
     focus:function(e){ 
      var textVal = myTextareaCellEditor.textarea.value; 
      textVal = decodeTEXT(textVal) ; 
      myTextareaCellEditor.textarea.value = textVal; 
     } 
}); 

myTextareaCellEditor.textarea.value : 텍스트 영역에 나타나는 값을 제공 할 것입니다. 이 값은 decodeText() 함수를 사용하여 디코딩하고 텍스트 영역 값을 바꿀 수 있습니다.

function decodeTEXT(textVal){ 
    textVal = textVal.replace(/&amp;/g, '&'); 
    textVal = textVal.replace(/&gt;/g, '>'); 
    textVal = textVal.replace(/&lt;/g, '<'); 
    textVal = textVal.replace(/&quot;/g, '"'); 
    textVal = textVal.replace(/&#39;/g, "'"); 

    return textVal; 
} 

희망이 있습니다. 코딩 즐기기 :)

+0

작품 Vivek, 대단히 감사합니다. –

관련 문제