Mark Mark - 7 months ago 21
Javascript Question

Make Keydown(enter) trigger Ajax.ActionLink when selected whith tab index

Could anyone help me out here?
I'm looking to trigger this(below) by just hitting the enter key:

<div id="create_new" tabindex="2">
@Ajax.ActionLink("Create New",
"create_new", new AjaxOptions {
UpdateTargetId="accordion",
InsertionMode= InsertionMode.Replace,
HttpMethod = "GET"
})
</div>

Answer

This works for me:

<div id="create_new">
@Ajax.ActionLink("Create New",
"create_new", "controller_name", null, new AjaxOptions
{
    UpdateTargetId = "accordion",
    InsertionMode = InsertionMode.Replace,
    HttpMethod = "GET"
}, new { tabindex = 2}
)
</div>

Just have the tabindex in the link instead of the div.