ext 图片预览事件触发以及IE7下预览图片

首先在FormPanel里添加图片预览区以及图片选择组件


/**
* 图片上传区
*/
this.imageUploadForm = new Ext.form.FormPanel({
region: 'east',
fileUpload: true,
width: 300,
split: true,
defaultType: 'textfield',
bodyStyle: 'align: center;',
defaults:{
hideLabel: true
},
items:[{
// labelSeparator: '',
id:'browseImage',
autoCreate:{
tag: 'input',
type: 'image',
src: Ext.BLANK_IMAGE_URL,
style:'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);'
name: 'imageBrowse'
}
},{
inputType: 'file',
id: 'imageUpload',
cls: 'upst'
}]

});


接下来添加选择完图片后的change事件

Global.img_reg=/\.([jJ][pP][gG]){1}$|\.([jJ][pP][eE][gG]){1}$|\.([gG][iI][fF]){1}$|\.([pP][nN][gG]){1}$|\.([bB][mM][pP]){1}$/
/**
* 浏览改变事件
* 只有当imageUploadForm render后Ext.get('imageUpload')才有效
*/
this.imageUploadForm.on('render',function(f){
this.imageUploadForm.form.findField('imageUpload').on('render',function(){
Ext.get('imageUpload').on('change',function(field,newValue,oldValue ){
var url = 'file:///'+Ext.get('imageUpload').dom.value;
if(Global.img_reg.test(url)){

if(Ext.isIE7){
var image = Ext.get('imageBrowse').dom;
image.src = Ext.BLANK_IMAGE_URL;//覆盖原来的图片
image.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src= url;
}else{
Ext.get('imageBrowse').dom.src = url;
}
}
},this);
},this);
},this);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值