清除 uikit html 编辑器

Clearing uikit html editor

本文关键字:编辑器 html uikit 清除      更新时间:2023-09-26

在保存关闭/取消模态时的数据后,我正在尝试清除我的 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);