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 h开发者_如何学JAVAave to click the "X" to close it...
What the heck am I doing wrong?
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();
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.
精彩评论