Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of null (reading 'getContent') #83

Open
SalomonHenke opened this issue Sep 1, 2024 · 3 comments
Open

Comments

@SalomonHenke
Copy link

SalomonHenke commented Sep 1, 2024

Specific code that throws the error:

const updateTinyVal = (id, val) => { if (getTiny() && getTiny().get(id).getContent() !== val) { getTiny().get(id).setContent(val); } };

Happens when i try to build it dynamically e.g.

This works:

foreach (var item in listOfItems)
{
    <Editor @bind-Text="item.Text"/>
}

This doesnt:

<Button OnClick="AddItemToListOfItems"/>
foreach (var item in listOfItems)
{
    <Editor @bind-Text="item.Text"/>
}

Not sure why.

@MRmP
Copy link

MRmP commented Sep 27, 2024

Same issue here when Editor was loaded multiple times

Maybe its related to #46 ?
I solved it temporary by just checking if get(id) is null or not.

@SalomonHenke
Copy link
Author

Same issue here when Editor was loaded multiple times

Maybe its related to #46 ? I solved it temporary by just checking if get(id) is null or not.

So before you call it e.g. say you create it via a lifecycle? or do you update the tinymce code?

A working example would be so helpful!! @MRmP

@MRmP
Copy link

MRmP commented Sep 28, 2024

@if (EditMode)
{
    <Editor @bind-Text="item.Text"/>
}

When i toggle EditMode On the first time, it loads correctly, When i set EditMode false, i've also tried to call the Editors dispose method manually, and EditMode back to true, it fails.

My quick solution was the following in tinymce-blazor.js

const updateTinyVal = (id, val) => {
    if (getTiny()?.get(id)?.getContent() !== val) {
        getTiny()?.get(id)?.setContent(val);
    }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants