在jquery UI模态对话框中嵌入SWF

embed swf in jquery ui modal dialog

本文关键字:SWF 对话框 jquery UI 模态      更新时间:2023-09-26

我在jquery ui模态对话框中嵌入了一个swf,当我打开swf播放的对话框,当我关闭对话框,并重新打开对话框而不刷新页面时,swf没有从第一次加载。当我关闭并打开对话框

时,我希望swf重新打开。

这是对话框的代码:

$( "#quiz" ).dialog({
    open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
    autoOpen: false,
    resizable: false,
    draggable: false,
    modal: true,
    width: 750,
    height:350
});
$( "#quiz-link" ).click(function( event ) {
    $( "#quiz" ).dialog( "open" );
       event.preventDefault();
    });
});

尝试在每次打开/关闭对话框时重新构建它的HTML。我认为你只是在展示& &;当前隐藏它,所以它永远不会重置。

试试这样:

$( "#quiz-link" ).click(function( event ) {
     // create a clone of your dialog
     var quiz_clone = $( "#quiz" ).clone().appendTo(body);
     quiz_clone.dialog({
        open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
        autoOpen: false,
        resizable: false,
        draggable: false,
        modal: true,
        width: 750,
        height:350
    });
    // destroy the clone when it's closed
    quiz_clone.on('close', function() {
        quiz_clone.dialog( "destroy" ).remove();
    });
    // show the clone
    quiz_clone.dialog( "open" );
    event.preventDefault();
});

$("#quiz").dialog({

open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
autoOpen: false,
resizable: false,
draggable: false,
modal: true,
width: 750,
height:350,
close: function(){
    $("#quiz").html(document.getElementById('quiz').innerHTML) ;
    }

});

    // Link to open the dialog
    $( "#quiz-link" ).click(function( event ) {
        $( "#quiz" ).dialog( "open" );
        event.preventDefault();
    });