Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
14012 Visualizzazioni

I have created a custom button in my form view. After clicking on the button I want to generate one alert. For that I have created the following code:

odoo.define('survey_inherit.button_click',function(require){

"use strict";

console.log('In button file');

var formView = require('web.FormView');

var relationFields = require('web.relational_fields');

var core = require('web.core');

var QWeb = core.qweb;

var formButton = formView.extend({

console.log('Test');

 self.$('#button_click').click(function (e){

alert('Test');

console.log('Button event');

});

});

return {

 formButton : formButton,

};});

But it gives me below error

Uncaught SyntaxError: Unexpected token '.'

what is the problem? Error is related to code?



Avatar
Abbandona
Autore Risposta migliore

I got a solution use formContoller instead of formView and change function for onClick event as follows:

var FormController = require('web.FormController');

var formController = FormController.include({
_onButtonClicked: function (event) {
if(event.data.attrs.id === "button_click"){
console.log('Test');
alert('Test');
relationFields._addTag('Test');
}
this._super(event);
},
});

Hope this will helpful others.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
mag 21
15802
1
apr 21
4468
1
apr 20
3126
0
mar 20
2269
1
feb 20
3985