From 2635ff9beef81de5166b6a73ca8c67a0532a8e6f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 29 Jan 2012 17:38:44 -0800 Subject: [PATCH] Fix: Grids will no longer display alerts when navigating to another page while the grid is still loading. --- NzbDrone.Web/NzbDrone.Web.csproj | 1 + NzbDrone.Web/Scripts/NzbDrone/Notification.js | 3 ++- NzbDrone.Web/Scripts/NzbDrone/grid.js | 4 ++++ NzbDrone.Web/Views/History/Index.cshtml | 6 ++++++ NzbDrone.Web/Views/Log/Index.cshtml | 6 ++++++ NzbDrone.Web/Views/Misnamed/Index.cshtml | 5 ++++- NzbDrone.Web/Views/Missing/Index.cshtml | 6 ++++++ NzbDrone.Web/Views/Series/Details.cshtml | 3 +++ NzbDrone.Web/Views/Series/Index.cshtml | 3 +++ .../Views/Shared/_ReferenceLayout.cshtml | 3 ++- NzbDrone.Web/Views/Upcoming/Index.cshtml | 21 +++++++++++++++++++ 11 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 NzbDrone.Web/Scripts/NzbDrone/grid.js diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index cecff258d..711a65f64 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -380,6 +380,7 @@ + diff --git a/NzbDrone.Web/Scripts/NzbDrone/Notification.js b/NzbDrone.Web/Scripts/NzbDrone/Notification.js index d5697be6e..1a6d7acee 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/Notification.js +++ b/NzbDrone.Web/Scripts/NzbDrone/Notification.js @@ -32,9 +32,10 @@ }); - jqXHR.error(function (xhr, ajaxOptions, thrownError) { + jqXHR.error(function (xhr, textStatus, thrownError) { //ignore notification errors. if (this.url.indexOf("/notification/Comet") !== 0) { + alert("Status: " + textStatus + ", Error: " + thrownError); $.gritter.add({ title: 'Request failed', text: this.url, diff --git a/NzbDrone.Web/Scripts/NzbDrone/grid.js b/NzbDrone.Web/Scripts/NzbDrone/grid.js new file mode 100644 index 000000000..9dfb5a307 --- /dev/null +++ b/NzbDrone.Web/Scripts/NzbDrone/grid.js @@ -0,0 +1,4 @@ +function grid_onError(e) { + //Suppress the alert + e.preventDefault(); +} \ No newline at end of file diff --git a/NzbDrone.Web/Views/History/Index.cshtml b/NzbDrone.Web/Views/History/Index.cshtml index 497acf2de..d82974c37 100644 --- a/NzbDrone.Web/Views/History/Index.cshtml +++ b/NzbDrone.Web/Views/History/Index.cshtml @@ -1,4 +1,5 @@ @model List +@using NzbDrone.Common @using NzbDrone.Web.Models @using NzbDrone.Web.Helpers @{ViewBag.Title = "History";} @@ -49,6 +50,11 @@ .Pageable( c => c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious)) + .ClientEvents(clientEvents => + { + if (EnviromentProvider.IsProduction) + clientEvents.OnError("grid_onError"); + }) .Render();}