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

I already searched a lot of posts, here(DOCS and Forum) and in the stack overflow, but i didn't get any example that works. What i want to do is very simple in fact. I need to put a javascript code to a button onclick event, in the button that already exists. All my attempts have failed. I think that my js code runs before right time, because it's always runs, so the HTML element still doesn't exists and nothing is added to element when it is loaded. 

One of a many ways that i have tried bellow:


(function(){
    "use strict";
    var _t = openerp._t;
    var _lt = openerp._lt;
    var QWeb = openerp.qweb;
    var oepetstore = openerp.oepetstore = {};
   
    oepetstore.Test = openerp.Widget.extend({
        events: {
            // events binding example
            "click .button_test": "myFunctionHandler",
        },
        
        myFunctionHandler: function(){
            alert('ok from button!');
        },
        
        start: function() {
            alert('ok!'); //this code always runs
        }
    });
   
    var pet = new oepetstore.Test();
    pet.appendTo(openerp.web.$el);
   
    return oepetstore;
})();
Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
dic 23
30706
2
lug 21
14014
1
dic 19
10103
1
apr 25
4917
0
ott 18
4055