1

I am trying to figure out the best way to call Javascript after Angular is done updating the UI.

My problem stems from the fact that KendoUI requires display:block in order to render properly. However, the Angular 2 change to this.toggleGridView is not rendered on the page yet, which causes jQuery("#schools-grid").height() to not work properly.

HTML template:

<im-schools-grid [style.display]="toggleGridViewState"></im-schools-grid>   

Angular 2 click handler:

toggleGridView() {
    this.toggleGridViewState = this.toggleGridViewState == "none" ? "block" : "none";

    if (this.toggleGridViewState == "block") {
        setTimeout((e) => {
            jQuery("#schools-grid").height(this.sharedGrid.gridHeight);
            jQuery("#schools-grid").data("kendoGrid").resize();
        }, 100)
    }
}

My current workaround is using setTimeout, but this seems very hackish.

Note- We cannot use Kendo for Angular 2 since it's a policy to not use Beta releases.

Thanks!

Chris Fremgen
  • 4,649
  • 1
  • 26
  • 26

0 Answers0