nic*_*los 10 javascript openerp
基本上我试图通过扩展它来覆盖一个函数.我有以下基础(简化)代码:
openerp.point_of_sale = function(db) {
var Order = Backbone.Model.extend({
exportAsJSON: function() {
return {'bigobject'}
}
})
}
Run Code Online (Sandbox Code Playgroud)
然后,我正在编写自己的.js,我想继承并覆盖exportAsJSON函数,我不知道如何扩展它.这是我错误的做法:
openerp.my_module = function(db) {
db.point_of_sale.Order = db.point_of_sale.Order.extend({
exportAsJSON: function() {
var order_data = this._super();
//... add more stuff on object
return order_data;
}
})
}
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?
我希望我能为答案提供足够的信息(我正在研究OpenERP).任何帮助将不胜感激.
编辑:更具体地说,错误似乎在扩展本身:
db.point_of_sale.Order = db.point_of_sale.Order.extend({
Run Code Online (Sandbox Code Playgroud)
......即使我把简单的回报0; 在我的exportAsJSON函数中,页面没有加载,我在浏览器控制台中收到以下错误:
"Cannot call method 'extend' of undefined"
Run Code Online (Sandbox Code Playgroud)
我想你想要这样的东西SuperClass.prototype.method.call(this):
openerp.my_module = function(db) {
db.point_of_sale.Order = db.point_of_sale.Order.extend({
exportAsJSON: function() {
var order_data = db.point_of_sale.Order.prototype.exportAsJSON.call(this);
//... add more stuff on object
return order_data;
}
})
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1047 次 |
| 最近记录: |