Bug Fix: Document Generation and SignalR iFrame

Performing page navigation (within an iFrame, or the top window) causes
the foreverFrame transport in SignalR to abort which takes several
seconds to reconnect. Popup windows are now used to navigate to Document
Generation API when the foreverFrame transport is in use.
This commit is contained in:
Gary Sharp
2014-06-02 19:06:07 +10:00
parent be25569245
commit 5510d34885
6 changed files with 571 additions and 473 deletions
@@ -228,10 +228,30 @@
$(function () {
var generatePdfUrl = '@Url.Action(MVC.API.Device.GeneratePdf(Model.Device.SerialNumber.ToString(), null))?DocumentTemplateId=';
var $documentTemplates = $('#Device_Show_GenerateDocument');
var $generationHost;
$documentTemplates.change(function () {
var v = $documentTemplates.val();
if (v) {
window.location.href = generatePdfUrl + v;
var url = generatePdfUrl + v;
if ($.connection && $.connection.hub && $.connection.hub.transport &&
$.connection.hub.transport.name == 'foreverFrame') {
// SignalR active with foreverFrame transport - use popup window
window.open(url, '_blank', 'height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
} else {
// use iFrame
if (!$generationHost) {
$generationHost = $('<iframe>')
.attr({ 'src': url, 'title': 'Document Generation Host' })
.addClass('hidden')
.appendTo('body')
.contents();
} else {
$generationHost[0].location.href = url;
}
}
$documentTemplates.val('').blur();
}
});