2017-08-02 57 views
0

我有一個場景,我上傳文件使用IFRAME。我想要的是成功上傳文件後,我想關閉modal彈出。但它不適用於我的情況。我試着像下面文件上傳提醒後關閉模式彈出

function CloseWindowFunction() { 
     alert('PDF uploaded successfully'); 
     $('.modal-dialog').modal('toggle'); 
    } 

也請參閱HTML爲同一

<div class="modal fade" id="dvFileUpload" tabindex="-1" role="dialog" aria-labelledby="dvFileUploadTitle" aria-hidden="true" data-backdrop="static" data-keyboard="false"> 
    <div class="modal-dialog" role="document"> 
     <div class="modal-content"> 
      <div class="modal-header"> 
       <h5 class="modal-title" id="exampleModalLongTitle">File Upload</h5> 
       <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 
        <span aria-hidden="true">&times;</span> 
       </button> 
      </div> 
      <div class="modal-body" data-keyboard="false"> 
       <iframe id="ifrmFileUpload" clientidmode="Static" runat="server" style="overflow: hidden; border: none" frameborder="0" scrolling="no"></iframe> 
      </div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> 
      </div> 
     </div> 
    </div> 
</div> 

所以,我應該怎麼關閉模式彈出,因爲我的代碼是不是有toggle財產的工作。

+0

可能的複製關閉(初始啓動後)](https://stackoverflow.com/questions/10495421/how-to-get-twitter-bootstrap-modal-to-close-after-initial-launch) –

回答

0

只要做到這一點

$('#dvFileUpload').modal('hide'); 

OR

$("#dvFileUpload .close").click(); 

OR

$('#dvFileUpload').removeClass('show'); 
+0

其中是'#mo dal'作爲ID在我的HTML? – BNN

+0

不能正常工作Manoj :( – BNN

+0

)你是否收到這個警報'alert('PDF uploaded successfully');'? – Manoj

1

我想你在調用內部iframe中的CloseWindowFunction()。如果是的話,請創建一個函數說hideModalPopup父頁面內:

function hideModalPopup(){ 
    $('.modal-dialog').modal('toggle'); 
    //OR - $('.modal-dialog').modal('hide'); 
} 

調用上述功能hideModalPopup()內CloseWindowFunction()這樣的。關閉窗口函數()編輯,下面檢查。

function CloseWindowFunction() { 
     alert('PDF uploaded successfully'); 
     window.parent.hideModalPopup(); 
} 
+0

其不工作夥伴 – BNN

0

嘗試添加一類模式的第一個div例如:

<div class="modal fade test-modal" id="dvFileUpload" tabindex="-1" role="dialog" aria-labelledby="dvFileUploadTitle" aria-hidden="true" data-backdrop="static" data-keyboard="false">

,然後調用[如何獲得Twitter的引導模式的

$('.test-modal').modal('hide'); 
+0

這也不工作 – BNN

+0

我使用iframe,可能是因爲它不工作 – BNN