1
while loading document viewer in a partial view and rendering it to a div is repeatedly loading the previously loaded file
Problem reported by vasanth - May 26 at 2:18 PM
Resolved
Hi, 
 
Whhile loading document viewer in a partial view and rendering it to a div is repeatedly loading the previously loaded file. 
 
When I load the data into an iframe i don't experience this issue. But in iframe the full screen feature is not working.
 
here is the function i use to load the document viewer in div, 
 
$.ajax({
            type: "GET",
            url: "/Home/GetFile",
            data: { id: Id },
            dataType: "html",
            cache: false,
            beforeSend: function () {
            },
            success: function (result) {
                $('#divFileView').empty();
                $('#divFileView').html(result);
            },
            error: function (error) {
            }
        });
 
Thanks,
Vasanth

3 Replies

Reply to Thread
0
Cem Alacayir Replied
May 26 at 2:37 PM
Employee Post
I guess that happens because DocumentViewer renders some JavaScript in the returned html which updates a JS array variable in the page. So as no page refresh occurs, that array keeps being updated and you always get the one from the first index. So it would be better to use an iframe, you can make the full screen work like this:
 
<iframe src=" ViewDocument?f=somefile.doc" width="800"  height="600" style="border: 1px solid #d0d0d0" allowFullScreen webkitallowfullscreen mozallowfullscreen>
 
By default browsers limit iframe "full screen" permission but when you put above properties, it will be allowed.
 
 
0
Cem Alacayir Replied
May 26 at 2:43 PM
Employee Post
If you don't want to use iframe, maybe you can do this in your partial view:
 
@Html.RenderControl(Model)

<script type="text/javascript">
	documentViewersToRender  = null
</script>
So after you render the DocumentViewer, you put this JS which clears the global array.
0
Cem Alacayir Replied
May 29 at 10:55 AM
Employee Post
For future reference, this should now work in v3.0.5:
 
Fixed: When rendering DocumentViewer in a MVC partial view called by AJAX, even when the HTML was cleared between repeated AJAX requests, DocumentViewer was still using the document and config from the first result. Made sure a global JS array is cleared after each DocumentViewer was rendered.

Reply to Thread