Skip to Content
Menu
This question has been flagged
1 Reply
3759 Views

Hi i am trying to render a component in a button click. I created a template and a component. But i don't know how link the button action and the component. Please guide.

Here is the code.

Buttonclick.js

          odoo.define('mobile_basket_verification.basket_menu', function (require) {
"use strict";

const MainMenu = require('stock_barcode.MainMenu').MainMenu;

MainMenu.include({
events: Object.assign({}, MainMenu.prototype.events, {

'click .basket_verification_line': function () {
this.do_action('mobile_basket_verification.BasketVerificationComponent');
},

}),
});
});
            
template.xml











Component.js

/** @odoo-module **/

const { Component } = owl;
const { useSubEnv, useState } = owl.hooks;

class BasketVerificationComponent extends Component{

}

BasketVerificationComponent.template = 'mobile_basket_verification.basket_verification';

Avatar
Discard
Best Answer

Hi,

Try like below code

odoo.define('mobile_basket_verification.basket_menu', function (require) {
"use strict";

const MainMenu = require('stock_barcode.MainMenu').MainMenu;
const { Component } = owl;
const { useSubEnv, useState } = owl.hooks;

class BasketVerificationComponent extends Component{
_mount(){
this.mount(document.body)
}
}

BasketVerificationComponent.template = 'mobile_basket_verification.basket_verification';

MainMenu.include({
events: Object.assign({}, MainMenu.prototype.events, {
'click .basket_verification_line': function () {
var basketVerification = new BasketVerificationComponent()
basketVerification._mount();
},
}),
});
});

Regards

Avatar
Discard
Related Posts Replies Views Activity
1
Sep 23
4490
0
Oct 22
571
1
Dec 23
1280
1
Oct 23
3545
2
Nov 22
12786