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

Editor is not working properly while attaching editor to a textarea returned from ajax #6

Closed
vneerukattu opened this issue Sep 11, 2017 · 8 comments
Assignees
Labels

Comments

@vneerukattu
Copy link

vneerukattu commented Sep 11, 2017

Editor is not working properly while attaching editor to a textarea from the data returned by ajax.
First time ajax request it is working from 2nd time on wards it is not working, is there a way we can clear something like cache etc.

I am seeing the following error in the console

jquery.richtext.js:626 Uncaught TypeError: Failed to execute 'selectNodeContents' on 'Range': parameter 1 is not of type 'Node'.
    at saveSelection (jquery.richtext.js:626)
    at doSave (jquery.richtext.js:720)
    at HTMLDivElement.<anonymous> (jquery.richtext.js:341)
    at HTMLDocument.dispatch (jquery-1.12.4.min.js:3)
    at HTMLDocument.r.handle (jquery-1.12.4.min.js:3)

Thanks
Kartheek

@webfashionist webfashionist self-assigned this Sep 11, 2017
@webfashionist
Copy link
Owner

What exactly are you trying to do? Are you calling the .richText() method more than once on the same input/textarea field?

You probably should create/initialize the editor once and update only the content through AJAX.

Please show me an example code of what you're trying to do.

@vneerukattu
Copy link
Author

Thank you for your quick response.
Please find the below URL where I written a sample code
Here is the URL : http://54.235.228.47

When I click "Show Form" first time it is working, but when I click second time it is not working.

@Pruus
Copy link

Pruus commented Sep 12, 2017

@vneerukattu:
-Have you edited in the js? Because the ? isn't visible on bottom right?
-If you make an other test, with a hyperlink what's going on then?

@webfashionist
Copy link
Owner

@vneerukattu:

Please use the latest version of RichText, quite a few updates have been made since the version you are working with.

However, the error you get might still occur on the latest version. Try creating an unique ID for your textarea in your PHP, return it to your AJAX code and start .richText() on this unique ID. This should make it work.

@vneerukattu
Copy link
Author

Hi

Updated with the latest version of Richtext, and also a unique ID for the textarea, but still now luck.
http://54.235.228.47

Thanks and Regards
Kartheek

@vneerukattu
Copy link
Author

Hi

It is working now, I changed a small piece of code in javascript.
Changed document.getElementById(editorID) to document.getElementsByClassName("richText-editor")[0] as it is not able to pick the updated id of the richText-editor div.

Once again thank you for the support

Regards
Kartheek

@webfashionist
Copy link
Owner

Thank you for your solution.
However, I suppose that your solution won't work if you have multiple editors on one page. I will try to resolve this issue anytime soon, but feel free to have a look on this yourself if you have time and motivation.

@webfashionist
Copy link
Owner

I've found the issue and updated the editor. In my tests, with the latest updates, AJAX "reloads" of the editor did work and I could as well load multiple editors at once this way.

Please keep me up-to-date if you encounter further issues.


This update is not yet in the releases list, if you need to download it, please do so by downloading it using the Clone or download button on the repository page.

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

No branches or pull requests

3 participants