PageDown with Bootstrap 3 modal dialog, background mask causes a lot of problems

Edit:
Check the bottom of this post for a solution, but now it introduces a new issue.

I am using the latest version of PageDown with Bootstrap 3.

This series of events raises the following error: Uncaught TypeError: Cannot call method 'removeChild' of null

At this moment, the wmd-background mask is also visible on top of my page.

After step 4, an error occurs :

  • Open custom modal dialog
  • Close the user modal dialog (using ok or cancel does not matter)
  • Open custom modal dialog
  • Close the user modal dialog (using ok or cancel does not matter)

Here's the javascript custom code:

var insert_image = $("#insert-image");
var submit_image = $("#insert-image-submit");
var insert_image_close = $("#insert-image-close-x, #insert-image-close");

var file_url = $("#file_url", insert_image);
var file_local = $("#file_local", insert_image);

editor.hooks.set("insertImageDialog", function(callback) {
  submit_image.on("click", function(event) {
    event.preventDefault();
    console.log("submit image");
    insert_image.modal("hide");
    return callback(file_url.val().length > 0 ? file_url.val() : null);
  });
  insert_image_close.on("click", function() {
    console.log("cancel");
    return callback(null);
  });
  insert_image.modal("show");
  return true;
});

editor.run();

, . Bootstrap , / wmd-background, , .

, data-backdrop="", html, , , , .

:
:

:
background.parentNode.removeChild(background);

:
if (document.contains(background)) { background.parentNode.removeChild(background); }

: , .

1, 2, 4, 6, 10 console.log , , .

, :

submit_image.unbind("click")
insert_image_close.unbind("click")

, , memoizing , + ?

+4

All Articles