Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have problems with multiple modal dialogs using IE 9 browser. When I click on the Ok or Cancel button on the second modal form, I get following exception from my js code.

http://imgur.com/qlL1H

when I try once again to press Ok or Cancel button I get

http://imgur.com/LY4We

It works fine on Chrome and Firefox.

on my first dialog I have a link button and this fires a standard js function

function AddContributor(id) {

    var currentUrl = window.location.href;
    currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/') + 1);

    var options = SP.UI.$create_DialogOptions();
    options.url = currentUrl + "/SecondPage.aspx?id=" + id;
    options.title = "Add";
    options.width = 700;
    options.height = 600;
    options.dialogReturnValueCallback = AddContributorCallback;

    SP.UI.ModalDialog.showModalDialog(options);
}

function AddContributorCallback(dialogResult, returnValue) {
    if (dialogResult == SP.UI.DialogResult.OK) {
        SP.UI.Notify.addNotification('xxx');
        SP.UI.ModalDialog.RefreshPage(dialogResult);
    }
    if (dialogResult == SP.UI.DialogResult.cancel) {
         SP.UI.Notify.addNotification('xxx.');
    }
}
share|improve this question

1 Answer 1

first looking at your code you have taken the if statment out of the try catch block where it should be inside the try block so you can catch the error when debugging.

The next issue is that it returning null, probably because its out of the try catch block and/or the object doesnt exist in that time when your clicking on it so your calling somthing (object) that hasnt been created yet or has been desposed off causing it to be null.

as i cant properly see a part of the code that could be causing it I can only speculate that you have click on the first modal which runs fine but then on the second one it throws the error as it doesnt exist what your calling or the code that its failing on is not in the right place!

hope this helps :)

share|improve this answer
    
Thanks for your reply. The code you have seen is not my code. It's standard sharepoint modal-dialog js. –  aph5 Sep 24 '12 at 13:23
    
ok no problem, so how did you add the dialog? –  ali Sharepoint Sep 24 '12 at 13:27
    
I have updated my question above. –  aph5 Sep 24 '12 at 13:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.