webuploader模態(tài)框ueditor顯示問題解決方法
webuploader 模態(tài)框 ueditor 顯示問題
模態(tài)框z-index 對應的值
.modal { z-index: 10050 !important; outline: none !important; }
遮罩層對應的z-index值
.modal-backdrop { border: 0 !important; outline: none !important; z-index: 10049 !important; }
ueditor 插件中,默認的z-index值為900 ;
在模態(tài)框中使用ueditor,可能會出現不兼容的情況,在ueditor.config.js里面修改z-index值,要比父級結構要大,否則,字體相關的下拉框還是會顯示異常,也可以覆蓋原來的z-index對應的樣式,
.edui-default{ z-index: 30111 !important; }
webupload 百度的上傳插件,如果在模態(tài)框中使用,會出現點擊無反應的情況,搜索得之,解決方式是在模態(tài)框顯示時調用shown.bs.modal 方法去初始化webuploader實例, 但結局就是每次顯示模態(tài)框都會導致選擇文件的按鈕越來越大。
以下是方式:
var $list=$("#thelist"); //這幾個初始化全局的百度文檔上沒說明,好蛋疼。 var $btn =$("#ctlBtn"); //開始上傳 var thumbnailWidth = 100; //縮略圖高度和寬度 (單位是像素),當寬高度是0~1的時候,是按照百分比計算,具體可以看api文檔 var thumbnailHeight = 100; $("#upload_pic").modal('show'); $("#upload_pic").on("shown.bs.modal",function(){ uploader = WebUploader.create({ // 選完文件后,是否自動上傳。 auto: false, // swf文件路徑 swf: base+'/statics/js/webUploader/Uploader.swf', // 文件接收服務端。 server: base + '/upload/uploadImg', // 選擇文件的按鈕??蛇x。 // 內部根據當前運行是創(chuàng)建,可能是input元素,也可能是flash. pick: '#filePicker', // 只允許選擇圖片文件。 accept: { title: 'Images', extensions: 'gif,jpg,jpeg,bmp,png', mimeTypes: 'image/*' }, method:'POST', }); // 當有文件添加進來的時候 uploader.on( 'fileQueued', function( file ) { // webuploader事件.當選擇文件后,文件被加載到文件隊列中,觸發(fā)該事件。等效于 uploader.onFileueued = function(file){...} ,類似js的事件定義。 var $li = $( '<div id="' + file.id + '" class="file-item thumbnail">' + '<img>' + '<div class="info">' + file.name + '</div>' + '</div>' ), $img = $li.find('img'); // $list為容器jQuery實例 $list.append( $li ); // 創(chuàng)建縮略圖 // 如果為非圖片文件,可以不用調用此方法。 // thumbnailWidth x thumbnailHeight 為 100 x 100 uploader.makeThumb( file, function( error, src ) { //webuploader方法 if ( error ) { $img.replaceWith('<span>不能預覽</span>'); return; } $img.attr( 'src', src ); }, thumbnailWidth, thumbnailHeight ); }); // 文件上傳過程中創(chuàng)建進度條實時顯示。 uploader.on( 'uploadProgress', function( file, percentage ) { var $li = $( '#'+file.id ), $percent = $li.find('.progress span'); // 避免重復創(chuàng)建 if ( !$percent.length ) { $percent = $('<p class="progress"><span></span></p>') .appendTo( $li ) .find('span'); } $percent.css( 'width', percentage * 100 + '%' ); }); // 文件上傳成功,給item添加成功class, 用樣式標記上傳成功。 uploader.on( 'uploadSuccess', function( file ) { $( '#'+file.id ).addClass('upload-state-done'); }); // 文件上傳失敗,顯示上傳出錯。 uploader.on( 'uploadError', function( file ) { var $li = $( '#'+file.id ), $error = $li.find('div.error'); // 避免重復創(chuàng)建 if ( !$error.length ) { $error = $('<div class="error"></div>').appendTo( $li ); } $error.text('上傳失敗'); }); // 完成上傳完了,成功或者失敗,先刪除進度條。 uploader.on( 'uploadComplete', function( file ) { $( '#'+file.id ).find('.progress').remove(); }); }); $btn.on( 'click', function() { uploader.upload(); });
解決每次點擊顯示modal導致上傳按鈕變大的方式為覆蓋由webuploader 生成的上傳按鈕樣式
.webuploader-pick{ padding: 0 !important; width: 82px !important; height: 38px !important; line-height: 38px !important; }
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
jQuery編輯器KindEditor4.1.4代碼高亮顯示設置教程
接下來介紹下編輯器KindEditor4.1.4代碼高亮顯示設置:加載需要的JS和CSS文件/編輯器初始化設置后,在里面加prettyPrint等等,感興趣的你可以參考下本文2013-03-03使用jQuery UI庫開發(fā)Web界面的簡單入門指引
這篇文章主要介紹了使用jQuery UI庫開發(fā)Web界面的簡單入門指引,jQuery UI是一個基于jQuery的圖形組件庫,需要的朋友可以參考下2016-04-04jQuery實現點擊DIV同時點擊CheckBox,并為DIV上背景色的實例
下面小編就為大家分享一篇jQuery實現點擊DIV同時點擊CheckBox,并為DIV上背景色的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12Juery解決tablesorter中文排序和字符范圍的方法
這篇文章主要介紹了Juery解決tablesorter中文排序和字符范圍的方法,實例分析了jQuery針對tablesorter中文排序和字符范圍的解決方法,需要的朋友可以參考下2015-05-05