0

当我尝试将这些动态生成的文本区域放入 CEditor 字段时,我收到错误:TypeError: b is undefined

我的代码:

    var input = $("<textarea>").addClass("textAreaClassTest");
    //input.setAttribute("id", "como");
    //input.setIdAttribute("id", "como");
    //input.ID = 'como';
    CKEDITOR.replace('como');
    item.append(input);
    //CKEDITOR.replace('como');

    return item;

我似乎无法给 textarea 一个 id - 任何 id 的 :)

4

1 回答 1

0

我假设您使用的是 jQuery,并且一次只能处理 1 个或多个文本区域。因此,您可以获取文本区域并为其分配 id 并按如下方式使用它们。

//select all text areas
var input = $("textarea");
var list = new Array();
var count = 0;

input.each(function () {
    count++;
    $this = $(this);
    $this.attr("id", "como" + count);
    console.log('id is "' + $this.attr("id") + '" and text is "' + $this.text() + '"');
    CKEDITOR.replace($this.attr("id"));
    list.push($this.attr("id"));
});
//return the list of replaced text area ids
return list;
于 2013-04-23T14:50:18.227 回答