Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
5996 Näkymät

I want to modify the DOM of the newly rendered view by jquery and extending the kanbanRenderer. However, some field widget is always rendered after my jquery function ( I have already tried to override different function, such as start, _renderview and etc), I guess it is something related to async feature of the javascript.

I wonder if there is a function called when the view rendering is just finished. Such that jquery can select any element of the finally DOM you can see on the browser. Below is some code within the my extension of kanbanRenderer, it is just not working.

let myKanbanRenderer1 = KanbanRenderer.extend({
start: function () {
return this._super().always(function(){
console.log($("span"))
})
}
})
Avatar
Hylkää
Tekijä

Thank you so much for you help !!

Paras vastaus

because the view is still detached from DOM so you could not access
you are right you can access an element from DOM after the start method executed but it's for Widget not for ViewRenderer.
ViewRenderer's lifecycle is different from Widget it handle by the action manager and view controller. 

Anyway, here If you want to access nodes of a renderer even it's still not attached to DOM. this.$el has a reference of it

let myKanbanRenderer1 = KanbanRenderer.extend({
    start: function () {
        var self = this;
        return this._super().always(function(){
            console.log(self.$('span'), self.$el)
        })
    }
})

 

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
marrask. 22
3408
1
kesäk. 25
456
1
kesäk. 25
389
1
toukok. 25
997
0
maalisk. 25
581