Div as Ajax.ActionLink [英] Div as Ajax.ActionLink
问题描述
是否可以创建Ajax.ActionLink,它具有整个DIV而不是文本?
Is it possible to create Ajax.ActionLink which has instead of text, the whole DIV?
我想在Ajax.ActionLink上映射div
I'd like to map div on Ajax.ActionLink
推荐答案
我认为使用标准MVC Ajax脚本无法解决此问题.我相信默认情况下会创建MVC javascript以使用<a>
元素.另外,在<a>
中嵌入div
标记不是有效的XHTML.您要达到什么目的?
I don't think that this will work using the standard MVC Ajax scripts. I believe that the MVC javascript is created to use an <a>
element by default. On a different note, embedding a div
tag within an <a>
is not valid XHTML. What are you trying to achieve?
使用Jquery可能是您想要的最简单的方法.例如:
Using Jquery is probably the easiet way you want to go. As an example:
<div onclick="SomeAjaxFunction()">some div content</div>
function SomeAjaxFunction()
{
$.get('<%= Url.Action("SomeAction", "InSomeController") %>', function(data) {
$('.result').html(data); // assuming a partial view
alert('Load was performed.');
});
}
但是,如果您不愿意使用MS Ajax来使用div,则可能需要查看Sys.Mvc.MvcHelpers._asyncRequest
函数并进行一些自己的重新包装以使其可用.我尚未尝试或测试,请自担风险. (与Jquery配合使用,可以获得更好的帮助和支持.)
However, if you are dead set on using MS Ajax, to work with divs, you need to possibly look at the Sys.Mvc.MvcHelpers._asyncRequest
function and do some of your own re-wrapping to make it usable. I have not tried or tested this, so use at your own risk. (Stick with the Jquery, there is far better help and support available.)
这篇关于Div as Ajax.ActionLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!