我缩短了以下脚本:
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"]'
});
});
错误发生在以下行:self.CalculateQuantityAssigned();
并且错误是Uncaught TypeError: Object [object Object] has no method 'CalculateQuantityAssigned'
。
我不明白。使用this
当然会失败,并且self
当我想访问self.options
但不用于self.CalculateQuantityAssigned()
.
谢谢。