Cannot read property 'field' of undefined (at _8 (jquery.numberbox.js:33))
问题描述:
页面端用了easyui的numberbox属性,然后在用js的方法修改值的时候,明明看到页面中的值是数字型(数量字段),
但是就是会报错
这种错误真的是很难理解,不过经过我的debug跟了一下,发现了问题所在,虽然页面中看到的是数字,但是在js代码中,赋值的时候,这个变量成了string类型了
很明显的发现,这个ProductQty的值是string了。
function ProductQty(newValue,oldValue) {
if(newValue && oldValue && newValue != oldValue) {
var row = $('#gridlist').datagrid('getSelected');
var index = $('#gridlist').datagrid('getRowIndex',row);
row.ProductQty = newValue;
row.SalePrice = row.ProductQty * row.OriginalPrice * (row.DiscountRate / 10);
$('#gridlist').datagrid('updateRow', {index: index, row: row});
$('#gridlist').datagrid('endEdit',index);
$('#gridlist').datagrid('beginEdit',index);
countPoint();
}
}
文件里标红的部分,发现了这个row对象里的ProductQty这个值变成了string类型了。
解决办法就是给这个转成Number即可
row.ProductQty = Number(newValue);
Cannot read property 'field' of undefined (at _8 (jquery.numberbox.js:33))的更多相关文章
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
最近把一个项目的jQuery升级到最新版,发现有些页面报错Cannot read property ‘msie’ of undefined.上jQuery网站上搜了一下,原因是$.browser这个a ...
- jquery升级到新版本报错[jQuery] Cannot read property ‘msie’ of undefined错误的解决方法(转)
最近把一个项目的jQuery升级到最新版,发现有些页面报错Cannot read property 'msie' of undefined.上jQuery网站上搜了一下,原因是$.browser这个a ...
- 一个关于EasyUI超恶心的BUG。。。Cannot read property 'options' of undefined
控制台Console抛出的异常: jquery.easyui.min.js:9148 Uncaught TypeError: Cannot read property 'options' of und ...
- Cannot read property ‘msie’ of undefined错误原因以及解决方案
最近把一个项目的jQuery升级到最新版,发现有些页面报错Cannot read property ‘msie’ of undefined.上jQuery网站上搜了一下,$.browser这个api从 ...
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法 --转
初用Yii的srbac模块.出现 Cannot read property ‘msie’ of undefined 错误.上网查询,找到如下的文章.使用文末的打补丁的方法,成功搞定.感谢. ===== ...
- 微信小程序跳转web-vie时提示appId无法读取:Cannot read property 'appId' of undefined
微信小程序报web-view错无法读取appId:Cannot read property 'appId' of undefined 问题描述: 我以前一直如下写代码没报错也都是可以使用的,并且小程序 ...
- UEditor使用报错Cannot set property 'innerHTML' of undefined
仿用UEditor的setContent的时候报错,报错代码如下Uncaught TypeError: Cannot set property ‘innerHTML’ of undefined.调试u ...
- AngularJs Type error : Cannot read property 'childNodes' of undefined
参考博客: https://blog.csdn.net/u011127019/article/details/73087868 在AngularJs和JQuery插件共存咋项目中经常会遇到如下异常 T ...
- Odoo14 TypeError: Cannot read property 'classList' of undefined
Traceback: TypeError: Cannot read property 'classList' of undefined at Class.setLocalState (http://l ...
随机推荐
- javascript数组&省市联动分别用js数组和JSON实现
1.定义数组的三种方式: **数组可以存放不同的数据类型 第一种: var arr=[1,2,3]; var arr=[1,"2",true]; 第二种: 使用内置对象 ...
- 通过重写ViewGroup学习onMeasure()和onLayout()方法
在继承ViewGroup类时,需要重写两个方法,分别是onMeasure和onLayout. 1,在方法onMeasure中调用setMeasuredDimension方法 void android. ...
- Percona-Tookit工具包之pt-slave-find
Preface If we want to check out how many slaves in our replication environment.We can execut ...
- 深入理解net core中的依赖注入、Singleton、Scoped、Transient(四)【转】
原文链接:https://www.cnblogs.com/gdsblog/p/8465401.html 相关文章: 深入理解net core中的依赖注入.Singleton.Scoped.Transi ...
- (原)Skeletal With DirectX12
@author: 白袍小道 @来源: Advanced Animation with DirectX, 游戏引擎架构 (暗影不解释连招) 引言: 3D模型动画的基本原理是让模型 ...
- HDU 1939 HE IS OFFSIDE
He is offside! Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- SPOJ AMR10I Dividing Stones
Time limit: 7s Source limit: 50000B Memory limit: 256MB The first line contains the number of test c ...
- 【bzoj4818】[Sdoi2017]序列计数 矩阵乘法
原文地址:http://www.cnblogs.com/GXZlegend/p/6825132.html 题目描述 Alice想要得到一个长度为n的序列,序列中的数都是不超过m的正整数,而且这n个数的 ...
- [CTSC2017][bzoj4903] 吉夫特 [状压dp+Lucas定理]
题面 传送门 思路 一句话题意: 给出一个长度为 n 的序列,求所有长度大于等于2的子序列个数,满足:对于子序列中任意两个相邻的数 a和 b (b 在 a 前面),$C_a^b mod 2=1$,答案 ...
- linux中sed工具的使用
sed 本身也是一个管线命令,而且 sed 还可以将数据进行取代.删除.新增.撷取特定行等等的功能. $ sed [-nefr] [动作] 选项与参数: -n :使用安静(silent)模式.在一般 ...