关于前端click事件的坑
来源:互联网 发布:se网络验证源码 编辑:程序博客网 时间:2024/06/06 03:26
对于click事件的绑定,一直是绑定下就可以了,但是在用jquery fileupload插件做文件上传的时候,每选择一次文件就会触发add属性对应的函数,导致多次绑定了click时间,一直多次调用后台上传文件,怎么查都找不到原因,最后才发现多次绑定click事件后,全部都会执行,而不是只执行最后一个click方法,记录下,以免以后被坑
$(this).fileupload({ url:WWWROOT+"/admin/fasdfs/upload", add: function (e, data) { var objClass = tdObj.find('input[type="text"]').attr('class'); if(objClass.indexOf('required') > -1){ tdObj.find('input[type="text"]').addClass('fileId'); } tdObj.find('a.fileBtn').removeClass('disabled').removeAttr('disabled'); tdObj.find('a.fileBtn') .click(function () { tdObj.find('a.fileBtn').addClass('disabled').attr('disabled','disabled'); if(disableBtn) { $(disableBtn).attr('disabled', 'disabled'); } if(loadingImage) { $(loadingImage).show(); } fileData.submit(); }); if(addFileCallBack){ addFileCallBack(); } }, done: function (e,data) { var result = data.result[0].body ? data.result[0].body.innerText : data.result; if(data.result[0].body){ result = eval('('+data.result[0].body.innerText+')'); }else{ result = eval('('+eval(data.result)+')'); } if(!result || !result.result || !result.result.fileId || result.result.fileId == ''){ bootbox.alert('文件上传失败!'); $(this).parent('span').parent('td').find('.progress .progress-bar').css('width',0); $(this).parent('span').parent('td').find('input[type="text"]').attr('value',''); $(this).parent('span').parent('td').find('input[type="text"]').attr('fileSize',''); $(this).parent('span').find("span.filename").find('input[type="text"]').attr('filetypevalue',''); }else { if(sucessCallBack){ sucessCallBack(result); } $(this).parent('span').parent('td').find('input[type="text"]').attr('fileidvalue',result.result.fileId); $(this).parent('span').parent('td').find('input[type="hidden"]').attr('value', result.result.fileId); } if(disableBtn) { $(disableBtn).removeAttr('disabled'); } if(loadingImage) { $(loadingImage).hide(); } }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $(this).parent('span').parent('td').find('.progress .progress-bar').css( 'width',progress + '%' ); } });
0 0
- 关于前端click事件的坑
- 移动前端—touch事件与click事件的区别
- jquery关于on click事件的理解
- 关于click事件与touch事件冲突的问题
- 关于 Touch事件和Click事件的冲突问题
- 关于点击click事件以及事件绑定的方式
- 关于JQ对checkbox的click事件触发的一个坑
- 关于jQuery的click事件不能触发的问题.
- jQuery中关于超链接click点击事件的注意点
- 关于动态添加的元素不能触发click事件
- on('click')与.click()事件的区别
- 动态添加的标签绑定click事件不响应和关于IOS下click事件委托失效的解决方案
- 修改 DBNavigator 的 click事件;
- HighCharts图的click事件
- 取消特定的click事件
- HighCharts图的click事件
- jquery的click事件失效
- 移动端的click事件
- SSO单点登录三种情况的实现方式详解
- mybatis数据库表字段名与实体类属性名不同的冲突之resultMap
- CMD 命令
- iOS 高德地图设置中心点,获取中心点的详细位置和经纬度
- thinkphp 模板截取中文字符串函数
- 关于前端click事件的坑
- Maven项目中提示javax.servlet.jsp cannot be resolved to a type
- 启动spring-boot报错java.lang.NoClassDefFoundError: javax/servlet/ServletContext
- C/C++训练1---最大公约数与最小公倍数 (sdut oj)
- Python用户交互
- Git学习记录
- 浅谈JAVA常用分布式实现方式及优缺点
- 三星Note7燃损原因公布多措并举保障未来产品安全
- Jquery实现的几款漂亮的时间轴