This question has been flagged
1 Reply
3074 Views

This code gives me a QWeb Runtime Error when self.my_variable is set too late:

start: function() {

    var self = this;

    var tmp = this._super.apply(this, arguments);

    var defs = [];

    defs.push(my_model.call("my_method", [self.dataset.context]).then(function(result) {

        self.my_variable = result;

    }));

    $.when(tmp, defs).then(function() {

        self.$el.find('.my_class').html(QWeb.render("my_qweb", {pass_to_qweb: self.my_variable}));
    });

    return $.when(tmp, defs);

}

Avatar
Discard
Author Best Answer

The solution was simple:

start: function() {

    var self = this;

    var tmp = this._super.apply(this, arguments);

    var defs = [];

    defs.push(my_model.call("my_method", [self.dataset.context]).then(function(result) {

        self.my_variable = result;

        self.$el.find('.my_class').html(QWeb.render("my_qweb", {pass_to_qweb: self.my_variable}));

    }));

}

Avatar
Discard