2014-02-19 51 views
0

我遇到了jquery ui對話框的問題。 一旦關閉它就無法打開。以下是我試過jquery ui對話框無法打開兩次

HTML:

<div id="videodialog" style="display:none;"> 
    <div style="top:0%; right:1%; position:absolute; cursor:pointer;" 
    class="videodialogremoveclass"><img id="dialogremove" src="image/bdelete.png"  
    height="15" /></div> 
    <iframe id="video" width="635" height="360" 
    src="http://www.youtube.com/embed/b16V25eNyJY" frameborder="0" allowfullscreen> 
    </iframe> 
    </div> 

的jQuery:

$('#videodialog').dialog({ 
     autoOpen: false, 
      height: 380, 
      width: '50%', 
      position:[285,140], 
      modal:true, 
      resizable: false, 
      draggable: false, 
      beforeClose: function(){ $(this).remove(); } 
    }); 
    $('#videodialog').dialog("open"); 
    e.preventDefault(); 

任何幫助,請:)

回答

1

刪除下面的行,它將關閉時從DOM中刪除對話框。

beforeClose: function(){ $(this).remove(); } 

繼續...

$('#videodialog').dialog({ 
     autoOpen: false, 
      height: 380, 
      width: '50%', 
      position:[285,140], 
      modal:true, 
      resizable: false, 
      draggable: false, 
      open: function() { $("#video").attr('src','http://www.youtube.com/embed/b16V25eNyJY'); } 
      beforeClose: function(){ $("#video").attr('src',''); } 
    }); 
+0

,但如果我不把那個,音頻仍然發揮即使我關閉對話框。 – Vidia

+0

您需要刪除iframe的src以停止播放視頻並在打開對話框時再次重新設置。 –

+0

yeahhh它的工作..謝謝一噸:) – Vidia

0

關閉事件之前刪除

$(this).remove(); 

0

爲達到這一目的,你寫了這行

e.preventDefault(); 
$(this).remove(); 

如果不需要,然後刪除,然後再試一次。