monad98/ng2-lazy-trumbowyg

initialContent does not display on rerendering component with Trumbowyg

Closed this issue · 9 comments

I'm using ng2-lazy-trumbowyg on a component which is inside an accordion. The page is loaded for the first time and when I click to open the accordion trumbowyg's initialContent is displayed as intended. Then when I close the accordion the component is destroyed, when I reopen the accordion after that the component loads as intended, but the initialContent is is never displayed.

The only solution I've been able to come up with is to use window.location.reload() on ngOnDestroy() of the component on which trumbowyg is usedbut this is obviously not ideal.

Any help or advice is appreciated.

Can I see the live example? don't have much time to do it by myself.
Thank you.

The problem also occurs for me. I've used trumbowyg inside modal and after first pop-up initial value was correctly displayed but after close and re-open a modal with new content it doesn't appear in trumbowyg.

My findings:

  • after first open of modal ngOnChanges inside Trumbowyg was called but second open doesn't trigger changes (new value correctly received in modal)
  • manually triggering Trumbowyg.content$.next(newContent) helps - new value is displayed inside the editor

Thanks @SirWojtek for feedback.
@monad98 Sorry, I've just not had time to look at this again yet, but I'll post a live example as soon as I'm able.

is it fixed now? I don't have time to test.

After updating to version 2.4.1 I get this:
ERROR TypeError: Cannot read property 'version' of null in the Trumbowyg service on line
27: this.TRUMBOWYG_PREFIX_URL = "https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/" + (config.version || '2.8.0');
Not sure if this is helpful at all, maybe I did something wrong when updating?

Please paste the file in which you include TrumbowygModule. In the new version, you should import TrumbowygModule in your root component:

class AppModule {
...
  imports: [
    TrumbowygModule.forRoot(),
  ]
...
}

Ah thanks @SirWojtek I somehow missed that...
@monad98 In my testing this works in ng2-lazy-trumbowyg version 2.4.1 so you can close this. Thanks for your patience and quick responses.

@synetax For the error, it's a bug. Using 'forRoot()' is optional. I will fix it tonight.