JS Error when background-closing a non-Editor foundation modal

JS Error when background-closing a non-Editor foundation modal

cbtdevcbtdev Posts: 39Questions: 12Answers: 0

We have a Foundation page with a DataTable and associated Editor. This page also contains a few reveal modals. After the page loads and I open a non-Editor modal, if I click on the reveal modal background to close it I get the following error:

Uncaught TypeError: Cannot read property 'background' of null
    (anonymous function) @ editor.foundation.js:56
    n.event.dispatch @ jquery.js:4435
    r.handle @ jquery.js:4121

After tracing this to the offending line of code, it seems that the editor is picking up ALL reveal-modal-bg click events and assuming it is part of an Editor modal. I updated that block of code to this and it fixed it for me (not sure it is the correct fix though)...

$(document).on('click', 'div.reveal-modal-bg', function () {
    if (self._dte) 
        self._dte.background();
} );

Also, as a side note, if I open an Editor modal first and then attempt the steps above, the error is not reproduced. I believe this is because the Editor sets self._dte when an Editor modal is opened.

Unfortunately, I am not able to provide a working example since the page is behind authentication, however, the debug code is uhuwul.

Thanks for your help,

Kurt

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi Kurt,

    Thanks for letting me know about this error with the Foundation integration. I've implemented a slightly different first - to have the click event on the background listened for only when the Editor control dialog is open - it is removed when the dialog is closed (then re-added when opened again, etc).

    Regards,
    Allan

  • cbtdevcbtdev Posts: 39Questions: 12Answers: 0

    Perfect! I assumed there was a more elegant approach. Will this go out with the next Editor release?

    Thanks again!
    Kurt

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Yes - it will be in 1.5.2.

    Allan

This discussion has been closed.