Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax.ActionLink in MVC3 Razor and loading gifs not working as expected
    primarykey
    data
    text
    <p>I am using AjaxOptions of in an Ajax ActionLink and I figured the loading gif would display within the UpdateTargetId (containerDiv) and it doesn't. I also expected the loading gif to run as long as the LoadingElementDuration, and it doesn't. No matter duration I use - the gif loads and fades out quickly (and appears to shrink as opposed to a straight fade). Am I missing something in my code that is preventing the expected behaviour from happening?</p> <pre><code>@{ ViewBag.Title = "Index"; } &lt;script type="text/javascript"&gt; function OnBeginAjax() { var item = $("#spanBegin"); item.text("Begin Request Fired!"); } function OnCompleteAjax() { var item = $("#spanComplete"); item.text("Complete Request Fired!"); } &lt;/script&gt; &lt;h2&gt;Index View&lt;/h2&gt; &lt;div id="spinner_container"&gt; &lt;img id="spinner" src="@Url.Content("~/content/themes/base/images/ajax-loader.gif")" class="hidden"/&gt; &lt;/div&gt; &lt;br /&gt; &lt;br /&gt; &lt;span id="spanBegin"&gt;Begin Request.....&lt;/span&gt;&lt;br/&gt; &lt;span id="spanComplete"&gt;Complete Request.....&lt;/span&gt; &lt;div&gt; @Ajax.ActionLink(" &lt;&lt; Fire Ajax Link", "AjaxMethod", new AjaxOptions { UpdateTargetId = "containerDiv", LoadingElementId = "spinner", LoadingElementDuration = 100000, OnBegin = "OnBeginAjax", OnComplete = "OnCompleteAjax" }) &lt;/div&gt; &lt;div id="containerDiv"&gt;&lt;/div&gt; </code></pre> <p>And if what I have (and what I'm seeing) is the expected behaviour (which seems pretty useless) - any ideas on how I would pass the UpdateTargetId as a param to the OnBegin function?</p> <p>Here's the rendered HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Index&lt;/title&gt; &lt;link href="/Content/Site.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/scripts/jquery.unobtrusive-ajax.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;h1&gt; MVC Sandbox Test Site&lt;/h1&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { // function OnBeginAjax() { // alert("Begin no params"); // // debugger; // // var item = $("#activityDiv"); // } // function OnCompleteAjax() { // alert("Complete no params"); // } }); function OnBeginAjax() { //alert("Begin no params"); // debugger; var item = $("#spanBegin"); item.text("Begin Request Fired!"); } function OnCompleteAjax() { var item = $("#spanComplete"); item.text("Complete Request Fired!"); } &lt;/script&gt; &lt;h2&gt;Index View&lt;/h2&gt; &lt;div id="spinner_container"&gt; &lt;img id="spinner" src="/content/themes/base/images/ajax-loader.gif" class="hidden"/&gt; &lt;/div&gt; &lt;br /&gt; &lt;br /&gt; &lt;span id="spanBegin"&gt;Begin Request.....&lt;/span&gt;&lt;br/&gt; &lt;span id="spanComplete"&gt;Complete Request.....&lt;/span&gt; &lt;div&gt; &lt;a data-ajax="true" data-ajax-begin="OnBeginAjax" data-ajax-complete="OnCompleteAjax" data-ajax-loading="#spinner" data-ajax-loading-duration="100000" data-ajax-mode="replace" data-ajax-update="#containerDiv" href="/Home/AjaxMethod"&gt; &amp;lt;&amp;lt; Fire Ajax Link&lt;/a&gt; &lt;/div&gt; &lt;div id="containerDiv"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload