mrackley
mrackley

Reputation: 121

SimpleModal breaks when .modal.close(); exists in script

I'm using SimpleModal in a SharePoint ContentEditorWebPart and it works great. However, I want to programatically close the window. I've tried different variations of the solution proposed here using $.modal.close():

How do you close a jQuery Simplemodal?

However, if I place "$.modal.close();" ANYWHERE in my script SimpleModal stops working... the text for my Modal pop up box displays ON the screen, the pop up box no longer appears at all.. it's as if I'm not using SimpleModal at all... If I comment out "$.modal.close();" the pop up box works fine again, but I have to click the "X" to close it...

What the heck am I doing wrong?

Upvotes: 1

Views: 3391

Answers (2)

John Lechowicz
John Lechowicz

Reputation: 2583

For situation like yours, where explictly calling

$.modal.close();

or

jQuery.modal.close();

is breaking, but the close button that comes with the modal is working properly, you can try simulating a click event using this:

$('.simplemodal-close').trigger('click');

That should hopefully close the modal for you when you want to close it explicitly in your javascript code.

Upvotes: 0

Eric Martin
Eric Martin

Reputation: 2841

Without seeing your code or a link to your page, it's hard to tell the exact reason. Instead of using $ for jQuery, can you try the following:

jQuery.modal.close();

Upvotes: 0

Related Questions