I am using an MVC grid that has a toolbar, with a custom button
toolBar.Custom().Text("Recalculate Assets").Action("Edit", "AssetPlanning", new { recalculate = true }).HtmlAttributes(new { title = "Warning: This could take multiple minutes to fully complete", data_toggle = "tooltip", id = ("calcButton" + uniqueName), onClientClick = "alert('reclacing');" });
This actionresult can take upto a minute to run. I would at the very least like to update the button to say calculating with a little spinner and whatnot
var buttonID = "#calcButton" & String(@uniqueName.ToString());
$(buttonID).click(function () { recalculating(); });
function recalculating() {
alert("reclacing");
$(buttonID).addClass("btn btn-lg btn-warning");
$(buttonID).html('<
span
class
=
"glyphicon glyphicon-refresh glyphicon-refresh-animate"
></
span
> Recalculating');
}
I would think that somewhere along the way the function would get called or an alert box would show, but nothing appears on the client side. I'm guessing that the action gets called first and the client click event just is never called. What can I do to make the client code called first or run together?