Javascript 清除uikit html编辑器

Javascript 清除uikit html编辑器,javascript,jquery,html,getuikit,Javascript,Jquery,Html,Getuikit,在保存关闭/取消模式时的数据后,我试图清除uikit html编辑器的内容 我试着用这些代码清除它: $("#description").val(''); $('#description').attr('data-uk-htmleditor'); $.UIkit.htmleditor('#description', { /* options */ }); 但它仍然不起作用。这里有人能帮我吗? 编辑: 以下是我从数据库中提取数据的其他代码: function editTask(id){ k

在保存关闭/取消模式时的数据后,我试图清除uikit html编辑器的内容

我试着用这些代码清除它:

 $("#description").val('');
 $('#description').attr('data-uk-htmleditor');
 $.UIkit.htmleditor('#description', { /* options */ });
但它仍然不起作用。这里有人能帮我吗? 编辑:

以下是我从数据库中提取数据的其他代码:

function editTask(id){
key = id;
s_type = 'u';
console.log(s_type);
enableForm('#task');

$('#btn-save-task').hide();
$('#btn-save-edited-task,#btn-cancel-task').show();
 $.ajax({
        type: "GET",
        url:  baseUrl+"/opportunities/getInfo/task/"+id,
        async    : true,
        data : {

            getType : "getTask"

                },
        dataType: 'json',
        error : function(req,error){
            notify(req.statusText,'warning');
        },
        success: function(data){
                    $("#taskDescription").val(data.description);
                    $('#taskDescription').attr('data-uk-htmleditor');
                    $.UIkit.htmleditor('#taskDescription', { /* options */ });

        }
    }); 
}试试这个:

var task = '';
function editTask(id) {
    key = id;
    s_type = 'u';
    console.log(s_type);
    enableForm('#task');

    $('#btn-save-task').hide();
    $('#btn-save-edited-task,#btn-cancel-task').show();
    $.ajax({
        type: "GET",
        url: baseUrl + "/opportunities/getInfo/task/" + id,
        async: true,
        data: {

            getType: "getTask"

        },
        dataType: 'json',
        error: function(req, error) {
            notify(req.statusText, 'warning');
        },
        success: function(data) {
            task = data.description;
        }
    });
}

$.UIkit.htmleditor('#taskDescription', { /* options */ });

//Get a reference to the CodeMirror editor
var editor = $('.CodeMirror')[0].CodeMirror;

//You can then use it as you wish
editor.setValue(task);

但它永久性地清除了我的编辑器,例如,我使用uikit html编辑器打开了一个要编辑的任务,我保存了它。然后它清除了编辑器。但是保存后,我想编辑另一个任务,当我单击编辑按钮时,它没有显示我数据库中的数据。您到底想要什么?您的问题清楚地表明,
我正在尝试清除我的uikit html编辑器的内容
是的,它清除了我的html编辑器,但在我的编辑器中保存编辑的文本后,它不会再次显示我要再次编辑的数据库中的数据,除非我刷新页面,否则我会遇到此错误sir
未捕获类型错误:无法读取未定义的属性“CodeMirror”
我遇到了相同的错误sir再次更新了答案:P