ckeditor / ckeditor4-angular

Official CKEditor 4 Angular component.
Other
55 stars 32 forks source link

Clicking on save button, refresh entire page #84

Closed brucebrit closed 4 years ago

brucebrit commented 4 years ago

Hi, Problem: When i click on the save button, it keeps refreshing the entire page. Question: I manage to capture the click event of the ckeditor4 buttons using the (click). But i can't prevent it from refreshing the entire page, despite me returning false in the click event handler function. Another Question: How do i check if the ckeditor4 button i have clicked is the save button?

jacekbogdanski commented 4 years ago

Save plugin just submits underlying editor form to the server using native browser mechanism, you can see the implementation here:

https://github.com/ckeditor/ckeditor4/blob/01b82d9d86eb1ebabf68934dcf71823f12bf7db8/plugins/save/plugin.js#L15-L31

For SPA apps built with frameworks like Angular, it doesn't really work as we don't want to refresh the whole page in most cases. So overall, you end up with a custom implementation where you intercept save event and calling own API:

editor.on( 'save', function() {
  callAPI( editor.getData() );
  // Prevent `save` command to be called.
  return false;
} );