最近我嘗試使用JavaScript OOP與jQuery, 我寫了這個代碼:的JavaScript - this.update不是一個函數
var beer = function(){};
$.extend(ntf.prototype, {
types:{
'.test':'test',
},
init:function() {
$.each(this.types, function(key, value) {
this.update(key, value);
});
},
update:function(className, actionName) {
$(className + ' .event').click(function() {
$(this).parent().find('.pevent').load('navigate.php?do=create&action=' + actionName);
alert("TEST");
}).click();
},
pics:{
add:function(element) {
$.post("navigate.php?do=nav&action=pics", {
name:$(element).data('name'),
});
}
}
});
beer.prototype.init();
但是,在控制檯它返回該錯誤:Uncaught TypeError: this.update is not a function
。
如何以更好的方式在jQuery中使用JavaScript OOP,以及如何解決此問題?
風扇謝謝!而且,在JavaScript OOP中使用jQuery有更好的方法嗎? –
我無法預測您使用此類比的方式中的任何問題。繼續,你會學習更多,當你使用它。 – Ash
如果它適合您,請將其標記爲答案,以便其他人可以找到它。 – Ash