开发者

ajax.Actionlink OnComplete never being called

I am using @Ajax.ActionLink to delete a record:

@Ajax.ActionLink("Delete","DeleteRun",new {RunId = run.RunId},
                     new AjaxOptions() { Confirm = "Are you sure you want to delete this entry?",
                                        HttpMethod = "DELETE",
                                        OnComplete = string.Format("DeleteRunInTable({0});",run.RunId)

                     })

Which produces the following link:

<a data-ajax="true" data-ajax-complete="DeleteRunInTable(11);" data-ajax-confirm="Are you sure you want to delete this entry?" data-ajax-method="DELETE" href="/Runs/Delete/11">Delete</a>

The delete is working perfectly but the OnComplete javascript function "DeleteRunInTable" is never called (i put a breakpoint in the javascript). Anyone know why?

Here is the javascript function (included as an external file):

    function DeleteRunInTable(RunId) {
       $("tr[data-runid=" + RunId).remove();
}

I've checked in chrome developer tools to make sure the scri开发者_JS百科pt is loading ok and it is. I also made sure jquery and jquery unobtrusive were being included.


Thanks i got it working. I changed the function a little:

function DeleteRunInTable(RunId) {
    //$("tr[data-runid=" + RunId).remove();
    $("tr[data-runid='" + String(RunId) + "']").remove();
    return false;
}

Don't know why it wasn't stopping at the break point before but now its working fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜