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 custom field. This field contains video. In Render method I open modal dialog (SP.UI.ModalDialog), and inside of this dialog I display a video (with WebControls:MediaWebPart). The modal is created with JavaScript:

function loadPlayVideoDialog(){
var options = {
    url: '(...)PlayVideo.aspx',
    autoSize: true,
    showClose: true,
    dialogReturnValueCallback: SP.UI.ModalDialog.RefreshPage};
SP.UI.ModalDialog.showModalDialog(options);

PlayVideo.aspx is a page in Layouts. It looks like this:

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<html>
<body>
    <table cellpadding="4" cellspacing="0" border="0" width="100%" style="margin-left:7px; margin-top:7px;">
        <tr>
            <td id="Td1" name="_invisibleIfEmpty" valign="top" width="100%"> 
                <WebPartPages:WebPartZone runat="server" Title="loc:FullPage" ID="WebPartZone1" FrameType="TitleBarOnly">
                    <ZoneTemplate>
                        <WebControls:MediaWebPart runat="server" ID="MediaWebPart1" PreviewImageSource="/Style Library/Media Player/VideoPreview.png" 
                            Height="340px" Width="420px" AutoPlay="True" ChromeType="None" Loop="False" 
                            Description="Use to embed media clips (video and audio) in a web page." 
                            DisplayMode="Inline" Title="Media Web Part" 
                            __MarkupType="vsattributemarkup" __WebPartId="{99a603f3-3a85-4711-a551-4ed586dbce23}" WebPart="true" __designer:IsClosed="false" partorder="2" />
                        <div style="float:right">
                            <asp:Button Text="Close" runat="server" ID="btClose" OnClientClick="javascript:closeDialog()" />
                        </div>
                    </ZoneTemplate>
                </WebPartPages:WebPartZone>
            </td>
        </tr>
    </table>
</body>
</html>

The problem is, that I cannot close the modal dialog. The 'X' button in the corner doesn't do anything. I even added a button, that calls SP.UI.ModalDialog.showModalDialog.close(); (see the btClose control?). It only reloads the video, but doesn't close the dialog.

Here's a screenshot: http://screencast.com/t/Xm3SlFP7fKG

What did I do wrong? How can I make close work?

share|improve this question
    
Out of curiosity, why aren't you using a the overlay player that ships with SharePoint. francois-verbeeck.posterous.com/… –  Anders Aune Mar 16 '12 at 16:19
    
That blog post is very good. I will go with this solution - video overlay instead MediaWebpart –  Tschareck Mar 22 '12 at 9:02
add comment

3 Answers

Definitely sounds like a JavaScript error as @default noted. Wanted to point out that your callback will not work as you are anticipating. SP.UI.ModalDialog.RefreshPage accepts a value of 1 or 0 for it to refresh the page. Try out my simple mods to your code:

function loadPlayVideoDialog() {
var options = {
    url: '(...)PlayVideo.aspx',
    autoSize: true,
    showClose: true,
    dialogReturnValueCallback: callback
};
SP.UI.ModalDialog.showModalDialog(options);
}

function callback( dialogResult ) {
    console.log(dialogResult);
    SP.UI.ModalDialog.RefreshPage(dialogResult); //will not refresh, form not submitted.
}

loadPlayVideoDialog();

If you open the debug tools and spot an error, feel free to post it.

share|improve this answer
    
This must be JS issue. At first i thought that because Item is opened in modal, and then I'm creating another modal nested in it, that could be cause. But when I open Item in new tab and then click on link, I'm being redirected to List View. –  Tschareck Mar 18 '12 at 22:13
    
@Tschareck I've done modals within modals before. It works just fine. You'll want to open up the browser's debugging tools and start the debugger. This may show you or hint at what is happening. –  iOnline247 Mar 22 '12 at 12:42
    
Why did you unmark this as an answer @Tschareck? –  iOnline247 Apr 11 '13 at 15:03
add comment

Probably you have a javascript error - please use IE dev toolbar or Firefox Firebug to see if there any error when you click on X.

share|improve this answer
add comment

The most possible reason of that is, that ModalDialog is opened from item form, that itself is also in ModalDialog. When dialog opens another dialog, closing the secfond dialog is not possible.

Related question here: Open SP.UI.ModalDialog within another ModalDialog

share|improve this answer
add comment

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.