-
Notifications
You must be signed in to change notification settings - Fork 396
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
Store doesn't seem to be updating #536
Comments
Does this work?
|
Ah yes - so, am I write in assuming then that And if we prevent the action, the event doesn't bubble, and the data is not saved? |
You are correct. At present the editor behaves like a textarea replacement so relies on the form submission to store the current state of the editor. |
Is there an event then that we can hook onto to know when the data has been saved? |
When you call https://github.com/madebymany/sir-trevor-js/blob/master/src/editor.js#L240-L256 The function above is the one that would normally be called when the form is submitted as can be seen here: https://github.com/madebymany/sir-trevor-js/blob/master/src/form-events.js#L19 |
Okay. |
Looking at that - this means that we have to add the event listener before initialising ST? |
You shouldn't need to as something like this would work. const el = document.querySelector('.sir-trevor');
const form = el.parentNode;
const editor = new SirTrevor.Editor({ el: el });
form.addEventListener('submit', function (e) {
e.preventDefault();
console.log(editor.store.toString(true));
}); |
When visiting the example page, if we edit the content, then run
SirTrevor.getInstance().store.retrieve();
in the console, thedata
array has not updated.Running the latest Chrome.
I wonder if perhaps Chrome has updated something around mutation - but either way, it has rendered the editor unusable.
Happy to help if I can - I was trying, but it's quite hard to debug.
The text was updated successfully, but these errors were encountered: