解决Ueditor在bootstarp 模态框中全屏问题

基本的一些配置就不说了。先说一下要注意的问题:首先是zIndex的设置。记住最好都显示设置模态框和ueditor的zIndex。理清他们的层叠关系。

特别是用到ueditor里面的图片上传功能的更要设好zIndex的值。具体要怎么设就不说了,有问题再讨论。

然后是模态框里的全屏问题:通常请款下模态框都比较小,让用户在模态框里的编辑器写东西,用户体验肯定不好。所以要将ueditor全屏。要使ueditor能在bootstrap模态框里正常全屏显示需要修改ueditor.all.js里面的setFullScreen函数

 

在 while (Container.tagName != "BODY") { }里面加上以下这段代码://解决在modal上ueditor不能全屏的问题

  

   var position = baidu.editor.dom.domUtils.getComputedStyle(container, "position");
                            nodeStack.push(position);
                            var isModal = false;
                            //判断该dom是否为modal
                            var classes = $(container).attr('class');
                            if (classes !== undefined) {
                                classes = classes.split(' ');
                                for (var i = 0; i < classes.length; i++) {
                                    if (classes[i] == "modal") {
                                        isModal = true;
                                    }
                                }
                            }
                            //如果是modal,则不设置position为static
                            if (!isModal) {
                                container.style.position = "static";
                            }
                            container = container.parentNode;

其实就是判断ueditor的父container是不是bootstrap模态框。如果是,则不将container.style.position设为static。否则全屏的ueditor会被其他元素覆盖掉

 

posted on 2017-07-05 17:05  OceanWang  阅读(1393)  评论(0编辑  收藏  举报

导航