解决部分浏览器下easyUI加载异常问题

        最近在开发一个文件上传的功能时,遇到一个很坑爹的问题,就是目前项目做的页面前端使用的是YUI框架,没找到详细的API文档,尤其是文件上传时需要用到弹窗功能,没法解决文件上传后后台返回前端时的数据处理,无奈之下只能另辟蹊径,启用了easyUI来做前端页面,由于浏览器使用的是IE(开发人员都知道IE是有多恶心,所以我选择的是比较旧版本的easyUI,所以官网上的有些案例无法使用),使用easyUI也出现了一些问题,不过好在只是页面渲染上的问题。

         首先看下h5代码(这里用到了struts2的s标签,这个可以忽略):

<s:form name="fml" id="form" method="POST" enctype="multipart/form-data">
	<div id="dd" title="扫描件上传" style="padding:5px;width:600px;height:350px;left: 300px;top: 100px;">
            <div style="margin-bottom:20px">
	        <input type="hidden" id="scanFlag"  value=""/>
		<table align="center" class="fix_table">
		    <tr align="center">
			<td class="long"><s:file name="scanImport" title="请选择文件路径" cssClass="button_ty">请选择文件路径</s:file>
			</td>
		    </tr>
		</table>
	    </div>
	    <table id="table-1" style="width: 570px;TABLE-LAYOUT: fixed;"> <!-- Replace "table-1" with any of the design numbers -->
		<thead>
		    <th>附件名</th>
    		    <th>操作</th>
		</thead>
		<tbody id="table-1-tb">
		</tbody>
	    </table>
	</div>
</s:form>

        异步提交成功后的js代码:

var businessLicense = {
		            "index":index1,
			    "fileName":getFileName(formData),
			    "url":data.msg.url
		        };
businessLicenseList.push(businessLicense);
//将对象数组转成json
var  jsonStr=arrToJsonStr(businessLicenseList);				       	
jQuery('#businessLicenseList').val(jsonStr);
//列表添加一行数据
jQuery('#table-1-tb').append('<tr>'+
			         '<input type="hidden" value='+index1 +'>'+
			         '<td style="WORD-WRAP: break-word;">'+
			            getFileName(formData)+
				 '</td>'+
				 '<td>'+
				     '<input type="hidden" value='+index1+'>'+
				     '<a href="#" class="easyui-linkbutton" onclick="viewFile(this)" iconCls="icon-search">查看</a>'+
				     '<input type="hidden" value='+data.msg.url +'>'+
				     '<a href="#" class="easyui-linkbutton" onclick="delBtn(this)" iconCls="icon-no">删除</a>'+
				 '</td>'+
			      '</tr>');

       测试后发现,easyUI的部分样式没被加载,如图:

       为什么会出现这种情况?其实很简单,easyUI对样式的加载是在页面加载之前,所以通过jquery的append方法添加的控件是在方法调用时候,所以样式没有加载,如果需要加载样式就需要调用方法结束之前通过手动进行加载,通过

$.parser.parse(content);

这个方法是easyui重载样式所使用的方法,可以无参,也可以有参,有参数的话需要放入一个jquery对象。修改完毕之后的代码如下:

var businessLicense = {
		            "index":index1,
			    "fileName":getFileName(formData),
			    "url":data.msg.url
		        };
businessLicenseList.push(businessLicense);
//将对象数组转成json
var  jsonStr=arrToJsonStr(businessLicenseList);				       	
jQuery('#businessLicenseList').val(jsonStr);
//列表添加一行数据
jQuery('#table-1-tb').append('<tr>'+
			         '<input type="hidden" value='+index1 +'>'+
			         '<td style="WORD-WRAP: break-word;">'+
			            getFileName(formData)+
				 '</td>'+
				 '<td>'+
				     '<input type="hidden" value='+index1+'>'+
				     '<a href="#" class="easyui-linkbutton" onclick="viewFile(this)" iconCls="icon-search">查看</a>'+
				     '<input type="hidden" value='+data.msg.url +'>'+
				     '<a href="#" class="easyui-linkbutton" onclick="delBtn(this)" iconCls="icon-no">删除</a>'+
				 '</td>'+
			      '</tr>');
//重新渲染表格
jQuery.parser.parse(jQuery("#table-1-tb"));

      完毕之后的效果如图:

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值