javascript - 清除 uikit html 编辑器

标签 javascript jquery html getuikit

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

关于javascript - 清除 uikit html 编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27417160/

相关文章:

java - 哪个选项适合替代 Java Applet?

javascript - Codewars - 如果元素出现超过 n 次,则删除该元素的出现

javascript - 在js中确定event.target下方的元素

javascript - 使用 jQuery 单击背景容器时隐藏元素

javascript - 限制特定大小的文件上传

php - 在 HTML 表格中显示 php 数组

javascript - 在 .aspx 页面上禁用右侧,但在超链接上启用

javascript - 如何在node.js中设置grpc客户端超时

javascript - 点击加载 html 时的 JQuery

javascript - 正则表达式匹配任何 Javascript/jQuery 函数声明行