Dav*_*ger 1 javascript jquery object
我缩短了以下脚本:
var HTH = HTH || {};
(function() {
var assetGrouping = function() {
var self = this;
this.options = {
_tmpElement: '',
QuantityAssigned: 0,
qtyInputField: ''
};
this.init = function(options){
// ...
this.options.QuantityAssigned = 0;
jQuery(this.options.qtyInputField).bind('keyup', function(){
self._tmpElement = jQuery(this);
self.CalculateQuantityAssigned();
});
// ...
}
CalculateQuantityAssigned = function(){
// ...
}
}
HTH.assetGrouping = new assetGrouping();
})();
$(document).ready(function(){
HTH.assetGrouping.init({
qtyInputField: 'input[name^="at700_group_qty"]'
});
});
Run Code Online (Sandbox Code Playgroud)
错误发生在以下行:self.CalculateQuantityAssigned();错误是Uncaught TypeError: Object [object Object] has no method 'CalculateQuantityAssigned'.
我不明白.this当然,使用将失败并且self在我想要访问时工作self.options但不是self.CalculateQuantityAssigned().
谢谢.
更改:
CalculateQuantityAssigned = function(){
// ...
}
Run Code Online (Sandbox Code Playgroud)
至
this.CalculateQuantityAssigned = function(){
// ...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1125 次 |
| 最近记录: |