I am using a HtmlHelper
to display an update to a user as follows:
In webpage:
<%=Html.CourseUpdateNotification() %>
In my controller:
public ActionResult UpdateOnceOnlyCourseRecord(some parameters)
{
//validation code etc...
//Save to database etc...
TempData["CourseUpdateNotification"] = "Success";
return RedirectToAction("ShowCourses", "Course");
}
At the moment, the notification to the user remains on the screen until the user navigates away from the page or refreshes the page (as expected).
The effect I would like to achieve is to display the notification but then fade it out after 3 seconds.
I tried to achieve this with the following jQuery:
(NOTE - The HtmlHelper
uses TagBuilder
to create a div
with the class attribute feedback-complete
)
$(document).ready(function() {
$(function() {
if ($('div.feedback-complete').length > 0) //Check if exists
{
setTimeout(function() { $('div.feedback-complete').fadeOut(); }, 3000);
}
});
});
Unfortunately this does not work for me and I cannot work out why. I have tried a few variations, including $(window).load
, etc. but to no avail.
Am I missing something more fundamental regarding HtmlHelper and how it can be accessed after the page load?
Insights always appreciated.