首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wysihtml5 brokes模式

Wysihtml5 brokes模式
EN

Stack Overflow用户
提问于 2019-07-23 16:11:35
回答 1查看 68关注 0票数 0

如果我在modal中使用wysihtml5,当我在使用wyshtml5的表单中打开modal时,它第一次工作得很好。但当我关闭modal,然后第二次打开它,然后wysihtml5功能不起作用时,它只显示文本区域,而不是工具箱和iframe。如果我关闭模型,并再次打开它的工作文件作为第一次。第四次同样的问题,arise.in other word wysihtml5在引导模式下交替工作。是wysihtml5错误,还是我做错了什么?

代码语言:javascript
复制
$(document).ready(function(e) {      
    $('#description').wysihtml5();
});

<div class="modal-body">         
<div class="alert alert-danger error_block" style="display: none"></div>
<form action="#" id="post_updt" novalidate="novalidate" enctype="multipart/form-data">
    <div class="row">
        <div class="col-md-8">
            <div class="form-group">
                <label class="control-label">
                    <h4>Title <span class="required" aria-required="true">* </span></h4>
                </label>
                <div class="controls">
                    <input type="text" placeholder="Post Title" id="post_title" name="post_title" class="col-md-12 form-control" required="true" value="">
                </div><label id="post_title-error" class="help-block help-block-error" for="post_title"></label>
            </div>
        </div>

    <div class="form-group post_description">
        <label class="control-label">
            <h4>Description</h4>
        </label>
        <div class="controls"> 
            <textarea id="description" name="description" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
        </div>
    </div>
    <div class="form-group event_dates hide">
        <label class="control-label">
            <h4>Event Dates <span class="required" aria-required="true">* </span></h4>
        </label>
        <div class="controls">
            <input type="text" placeholder="Event Dates" id="event_dates" name="event_dates" class="col-md-12 form-control">
        </div>
    </div>
</form> 

代码语言:javascript
复制
$(document).ready(function(e) {
    $("#post_type").change();      
    $('#description').wysihtml5();
});

$("#post_type").on('change', function () {
    var vl = $(this).val();
    $("#file_url").removeAttr("required");
    if (vl == 'Event') {
        $(".event_dates").removeClass("hide");
        $(".upld_document,.post_description").addClass("hide");
    } else if (vl == 'Document') {
        if($("#old_file").val()==""){
            $("#file_url").attr("required","true");
        }
        $(".upld_document").removeClass("hide");
        $(".post_description,.event_dates").addClass("hide");
    } else {
        $(".upld_document,.post_description").removeClass("hide");
        $(".event_dates").addClass("hide");
    }
});
EN

回答 1

Stack Overflow用户

发布于 2020-04-18 21:42:25

是的,有一个bug。当你在modal中使用wysihtml5时,你应该在modal上初始化它,并且你应该在modal消失时移除它。

代码语言:javascript
复制
jQuery(document).ready(function () {

    $('#modal_Event').on('shown', function () {
        $('#description').wysihtml5();
    });

    $('#modal_Event').on('hidden', function () {
        $('.wysihtml5-sandbox, .wysihtml5-toolbar').remove();
        $('#description').show();//optional
    });

});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57159588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档