1
您好,我試圖在odoo後端的窗體視圖上顯示chessboardjs,我最終使小部件顯示板,但件被隱藏,我不知道爲什麼,因爲似乎工作正常,除了件。如果我在選項中使用了dragable : true
並移動了一個隱藏的棋子,那麼棋盤上的所有棋子都會呈現出來。我是否錯過了一些東西,在我的代碼中,棋盤沒有被渲染好? 這裏是MI部件代碼:試圖顯示在odoo窗體部件中的棋盤js,沒有錯誤沒有片段
(function (instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
openerp.chess_base = function (instance, local) {
local.YourWidgetClassName = instance.web.form.FormWidget.extend({
start: function() {
this.$el.append('<div id="board" style="width: 300px">BOARD GOES HERE</div>'); // creating the board in the DOM
this.onBoard();
},
onBoard: function (position, orientation) {
if (!position) {
this.position = 'start'
} else {
this.position = position
}
if (!orientation) {
this.orientation = 'white'
} else {
this.orientation = orientation
}
this.el_board = this.$('#board');
this.cfg = {
position: this.position,
orientation: this.orientation,
draggable: false,
pieceTheme: '/chess_base/static/img/chesspieces/wikipedia/{piece}.png'
};
this.board = ChessBoard(this.el_board, this.cfg);
}
});
instance.web.form.custom_widgets.add('widget_tag_name', 'instance.chess_base.YourWidgetClassName');
}
})(openerp);