-
Notifications
You must be signed in to change notification settings - Fork 153
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
How can I init a preview / textarea dynamically after page has finished loading? #212
Comments
Right, so you want to reinitialise MarkdownX then. Here's the code that initialises the process when DOM has loaded. My understanding is that you want to reinitialise this, which means you want to run this part again: docReady(() => {
const ELEMENTS = document.getElementsByClassName('markdownx');
return Object.keys(ELEMENTS).map(key => {
let element = ELEMENTS[key],
editor = element.querySelector('.markdownx-editor'),
preview = element.querySelector('.markdownx-preview');
// Only add the new MarkdownX instance to fields that have no MarkdownX instance yet.
if (!editor.hasAttribute('data-markdownx-init'))
return new MarkdownX(element, editor, preview)
});
}); |
I'd also like to do this. When I've tried to replicate something similar to the above I've struggled because I've tried everything I can think of to import
|
Just done some playing around on a fork of the repository. What worked for me to be able to import I found I could then include I'll do a pull request for the change to the build step - but not sure if this is the right approach. |
Thanks @xenatisch that approach makes sense 👍 |
I'd like to dynamically add a markdown preview and textarea to a form. From what I can tell, the Javascript looks out for markdownx fields on DOMContentLoaded. My problem is that the inputs I'd like to dynamically insert likely take place after the DOMContentLoaded event.
Is there a way I can do this without altering the Javascript already in the project?
The text was updated successfully, but these errors were encountered: