开发者

Showing both MVC Ajax calls and jQuery Ajax calls with one indicator

I have a web application that utilises both the MVC Ajax calls: Html.ActionLink() rendering as Sys.Mvc.AsyncForm.handleCl开发者_运维知识库ick( in the page source

and: jQuery Ajax calls, eg:

$.post()

Now I can easily set a generic Ajax indicator to show and hide when the jQuery is making an Async call using:

  $('#indicatorId').ajaxStart(function() {
                $(this).show();
            }).ajaxStop(function() {
                $(this).hide();
            });

And I can set some functions to show and hide the same indicator by passing values into the constructor of the Ajax.ActionLink constructor and setting OnBegin and OnComplete, but this means that I have to do this EVERYTIME I add a new Ajax.ActionLink to the site.

Is there a better way to do this? Perhaps I could scan the DOM after it's rendered and add the generic events then?

Any thoughts, better examples?


Unless you've a compelling reason (I've never found one) you shouldn't mix jQuery and MS Ajax into the same site and unless you've a compelling reason you should prefer jQuery. So, no need to use Ajax.* helper methods which tend to pollute the markup with javascript.

Do it the jQuery way, unobtrusively.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜