DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
223 stars 79 forks source link

AjaxActionLink ignoring OnSucces #285

Closed Yustie closed 10 years ago

Yustie commented 10 years ago

Hi,

Somehow my modal popup is not firing any more. Not sure if it was because of the last update, but this is the line:

@dd.AjaxActionLink(Resources.Objects.Cancel, "Update", "Home", new AjaxOptions { HttpMethod = "POST", OnSuccess = "window.location.reload(true)" }).Confirm(Resources.Form.ConfirmCancel).RouteValues(new { pId = item.Id, status = Status.Cancelled, @type = RoleType.Customer }).PrependIcon("glyphicon glyphicon-remove")

This is the generated html:

<a data-ajax="true" data-ajax-method="POST" data-ajax-success="window.location.reload(true)" data-bmvc-confirm="true" data-bmvc-confirm-text="You sure you want to cancel?" href="/Home/Update?pId=35&amp;status=Cancelled&amp;type=Customer"><i class="glyphicon glyphicon-remove">

It goes straight to the controller, it does try to show the modal, but it's like it's getting interrupted before it can be displayed.

if I remove the RouteValues(), the modal does get displayed. But then it doesn't do much.

Yustie commented 10 years ago

It seems that this does work: new AjaxOptions { HttpMethod = "POST", OnSuccess = "window.location.reload(true)", Confirm = "test" But this is inside the AjaxOptions. So how come the fluent api function Confirm() doesn't work?

Yustie commented 10 years ago

Never mind, the problem was caused by this script: <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> which also catches the click events of data-ajax-* classes.

DmitryEfimenko commented 10 years ago

Glad you could figure it out while I was out of town!