E
E
Eugene2019-08-02 18:59:22
JavaScript
Eugene, 2019-08-02 18:59:22

How to catch an event when Handlebars has generated a template?

Tell me such a moment how to correctly catch events that Handlebars rendered the template.
Ajax loads the data, after which the template is built. And it turns out that the "complete" Ajax request function fires before Handlebars builds templates based on this data.

$.ajax({
    url: urlData,
    type: "get",
    async: true,
    cache: false,
    timeout: 30000,
    success: function (data) {
        if(data.length > 0) {
            var template = Handlebars.compile($('#templateInvoice').html());
            resultContainer.html(template(data));
        }
    }, complete: function (data) {
        // Тут срабатывает раньше чем, Handlebars отрисует шаблоны
    }
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question