2014-06-13 4 views
4

Je rends une vue partielle si ajax dans Iframe de la vue principale. Et cela fonctionne très bien, mais localement après la publication de ses œuvres ne première fois deuxième fois, il efface corps iframeIframe ne rend pas le contenu une deuxième fois

Voici mon code:

$('#editFaxdialog').dialog({ 
     autoOpen: false, 
     title: 'Edit PDF', 
     height: 'auto', 
     width: '80%', 
     position: ['top', 50], 
     draggable: false, 
     show: 'blind', 
     hide: 'blind', 
     modal: true, 
     open: function (event, ui) { 
      $.ajax({ 
       url: '@Url.Action("EditPdf", "Fax")', 
       type: 'GET', 
       cache:false, 
       success: function(data){ 
        var frameSet = document.getElementById("editFaxFrame"); 
        var iframedoc = frameSet.document; 

        if (frameSet.contentDocument) 
         iframedoc = frameSet.contentDocument; 
        else if (frameSet.contentWindow) 
         iframedoc = frameSet.contentWindow.document; 

        if (iframedoc){ 
         iframedoc.open(); 
         iframedoc.writeln(data); 
         iframedoc.close(); 
        } 
       }, 
       error: function() { 
        window.location.href = '@Url.Action("Index","Error")'; 
       } 
      }); 
     }, 
     close: function (event, ui) { 
      $("#editFaxFrame").attr("src", ''); 
     } 

    }); 
+0

Est-ce que chaque fois que votre iframe est ouvert, la publication est-elle effectuée? –

+0

Y a-t-il des choses qui se produisent même pendant que le temps est écoulé? – Kajal

+0

Y at-il des erreurs? –

Répondre

2

Je résolu ce problème après tant r & di mettre la fonction setTimeout() sur succès ajax

$('#editFaxdialog').dialog({ 
     autoOpen: false, 
     title: 'Edit PDF', 
     height: 'auto', 
     width: '80%', 
     position: ['top', 50], 
     draggable: false, 
     show: 'blind', 
     hide: 'blind', 
     modal: true, 
     open: function (event, ui) { 
      $.ajax({ 
       url: '@Url.Action("EditPdf", "Fax")', 
       type: 'GET', 
       cache:false, 
       success: function(data){ 
        setTimeout(function() { 
        var frameSet = document.getElementById("editFaxFrame"); 
        var iframedoc = frameSet.document; 

        if (frameSet.contentDocument) 
         iframedoc = frameSet.contentDocument; 
        else if (frameSet.contentWindow) 
         iframedoc = frameSet.contentWindow.document; 

        if (iframedoc){ 
         iframedoc.open(); 
         iframedoc.writeln(data); 
         iframedoc.close(); 
        } 
},400); 
       }, 
       error: function() { 
        window.location.href = '@Url.Action("Index","Error")'; 
       } 
      }); 
     }, 
     close: function (event, ui) { 
      $("#editFaxFrame").attr("src", ''); 
     } 

    }); 
Questions connexes