我遇到了yui TextAreaCellEditor的问题。
在yui语句下方打开编辑器,单击yui列时会显示“保存”和“取消”按钮。
var myTextareaCellEditor = new YAHOO.widget.TextareaCellEditor();
var myColumnDefs = [
{key:"title",label:"Title", sortable:true ,editor: myTextareaCellEditor},
];
现在我的问题是,当我指定标题并保存在数据库中时,例如我的标题是&#34; text&data<new>
&#34;。
它正在保存,但是当我打开包含标题文本的编辑器时。
它显示为&#34; text&data<new>
&#34;。
我想从编辑器中删除html实体。
非常感谢任何帮助。
答案 0 :(得分:2)
TextareaCellEditor 有一个名为“焦点”的事件,当编辑器被初始化并且焦点在它上面时,会调用Focus函数,您可以使用它。
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()函数解码此值并替换textarea值。
function decodeTEXT(textVal){
textVal = textVal.replace(/&/g, '&');
textVal = textVal.replace(/>/g, '>');
textVal = textVal.replace(/</g, '<');
textVal = textVal.replace(/"/g, '"');
textVal = textVal.replace(/'/g, "'");
return textVal;
}
希望这会有所帮助。享受编码:)