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

CKEditor not firing dirty and clean events #132

Open
StuffOfInterest opened this issue Sep 21, 2018 · 1 comment
Open

CKEditor not firing dirty and clean events #132

StuffOfInterest opened this issue Sep 21, 2018 · 1 comment

Comments

@StuffOfInterest
Copy link

I recently implemented DirtyForms with both the CKEditor and Bootstrap plugins. The dirty state tracking and dialog intercepts seem to be working (although it will on occasion not catch the back button). The main problem I'm seeing is that CKEditor is not firing the dirty and clean events. I implemented the code below from the documentation so enable and disable buttons based on dirty state:

$('form').find('[type="reset"],[type="submit"]').attr('disabled', 'disabled');
$('form').on('dirty.dirtyforms clean.dirtyforms', function (ev) {
    var $form = $(ev.target);
    var $submitResetButtons = $form.find('[type="reset"],[type="submit"]');
    if (ev.type === 'dirty') {
        $submitResetButtons.removeAttr('disabled');
    } else {
        $submitResetButtons.attr('disabled', 'disabled');
    }
});

For the text box controls on the page the submit and reset buttons are being disabled and enabled based on the state. Unfortunately, making changes in the CKEditor input has no effect. CKEditor is changing the dirty flag because if I make any edits in that box the dialog will popup when I try to navigate off page.

@bpug
Copy link

bpug commented Oct 11, 2018

I had the same problem, but with other editor 'summernote'
I solved that:

$('form').on('dirty.dirtyforms clean.dirtyforms summernote.change',  function (ev) {
      var $form = ev.target.form ? $(ev.target.form) : $(ev.target);
      var isDirty = $form.dirtyForms('isDirty');
      var $submitResetButtons = $form.find('[type="reset"],[type="submit"]');
       if (isDirty) {
              $submitResetButtons.removeAttr('disabled');
       } else {
              $submitResetButtons.attr('disabled', 'disabled');
       }
});

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

No branches or pull requests

2 participants