question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Best way to listen to changes on the final HTML?

See original GitHub issue

Hi,

I just had a quick question because I could not figure out how to do it or did not find an issue related to it.

I am just trying to call a function when any changes is done on the canvas.

For example, I am adding a block or removing a block. I am changing the attributes using the style manager. Or drag and dropping the blocks within the canvas. Or even updating the traits.

Is there a global event I can listen to it trigger my function?

I am not talking about any actual changes in the Canvas itself but changes that apply to the final HTML when I call the method editor.getHtml().

Any help or guidance is appreciated, thanks!

Update:

For the moment I figured out I could use the storage manager to achieve this, by doing:

storageManager: { type: 'onChange'; }

and 

editor.on('storage:start', callback);

If there is a simpler solution without having to do it this way, I am open to suggestions.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
a-bashtannikcommented, Mar 7, 2019

@simplecommerce , try also this, maybe fit better for you

editor.on('change:changesCount', e => {
// Change!
    });
1reaction
arthuralmeidapcommented, Mar 6, 2019

The way you did is the simplest way to achieve that in my opinion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to listen to a change event in all/any of the fields of a ...
$(document).on('change', '.field', function() { /* recalculate */ });.
Read more >
HTMLElement: change event - Web APIs | MDN
Use the event name in methods like addEventListener() , or set an event handler property. addEventListener('change', (event) => ...
Read more >
Structural markup and right-to-left text in HTML - W3C
This article looks at ways of handling text direction for structural markup in HTML, ie. at the document level and for elements like ......
Read more >
JavaScript Events Examples - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >
Questions and Answers About Health Care Directives
How Long Does a Health Care Directive Last? Can I Change It? Your health care directive lasts until you change or cancel it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found