zoukankan      html  css  js  c++  java
  • layui的编辑器 layedit的异步赋值问题

    layedit 需要先构建编辑器 再输出数据

    如果取值 慢于 构建编辑器  那么数据在编辑器中就无法显示了

    layui.use('layedit',function() {
    var layedit = layui.layedit;

    //构建一个默认的编辑器
    var index = layedit.build('LAY_demo1');
    });

    //js本地赋值
    $(document).ready(function() {
    var $title1 = $("#newsTitle_1");
    var $content1 = $("#LAY_demo1");
    var $person1 = $("#newsPerson_1");
    var $time1 = $("#newsTime_1");
    $.ajax({
    url: '../json/newsTable.json',
    type: 'get',
    data: " ", //入参
    dataType: 'json',
    timeout: 6000,
    async: false,
    success: function(retData) {
    //console.log(retData);
    $title1.val(retData[0].newsTitle);
    $content1.val(retData[0].newsContent);
    $person1.text(retData[0].newsPerson);
    $time1.text(retData[0].newsTime);
    },
    error: function(request,testStatus,errorThrown){
    //执行错误的方法
    if(testStatus == "timeout"){
    alert("请求超时!");
    }
    }
    })
    });

    //先赋值再构建编辑器(异步问题)
    $(document).ready(function() {
    var $title1 = $("#newsTitle_1");
    var $content1 = $("#LAY_demo1");
    var $person1 = $("#newsPerson_1");
    var $time1 = $("#newsTime_1");
    $.ajax({
    url: '../json/newsTable.json',
    type: 'get',
    data: " ", //入参
    dataType: 'json',
    timeout: 6000,
    async: false,
    success: function(retData) {
    //console.log(retData);
    $title1.val(retData[0].newsTitle);
    $content1.val(retData[0].newsContent);
    $person1.text(retData[0].newsPerson);
    $time1.text(retData[0].newsTime);
    },
    error: function(request,testStatus,errorThrown){
    //执行错误的方法
    if(testStatus == "timeout"){
    alert("请求超时!");
    }
    }
    })
    layui.use(['layer','layedit','laypage','element'],function() {
    var layer = layui.layer,
    layedit = layui.layedit;

    //构建一个默认的编辑器
    var index = layedit.build('LAY_demo1');
    });
    });
  • 相关阅读:
    ConcurrentSkipListMap 源码分析
    ConcurrentHashMap 源码分析
    CopyOnWriteArrayList 源码分析
    AtomicBoolean 源码分析
    commons-lang3-3.4.jar
    Effective Java
    FindBugs Bug Descriptions
    EasyMock
    Apache Maven 入门
    Eclipse
  • 原文地址:https://www.cnblogs.com/miny-simp/p/6849112.html
Copyright © 2011-2022 走看看