Ajax.ActionLink插入表头之后? [英] Ajax.ActionLink insert after header in a table?
问题描述
我有一个带有标题行的< table>
.我正在尝试在标题行下添加一个项目,但似乎无法将这种意图描述给 ActionLink
函数.
I have a <table>
that has a header row. I'm trying to add an item under the header row, but there seems to be no way to describe this intent to the ActionLink
function.
InsertionMode.InsertBefore
将该行放在表的顶部, Replace
替换表的头,然后 InsertAfter
实际上将新行放在标题行中-显然是无效的.
InsertionMode.InsertBefore
with the header row's ID specified as the update target just puts the row on the top of the table, Replace
replaces the header of the table, and InsertAfter
actually puts a new row inside the header row -- which is obviously invalid.
是否有任何方法可以指定我要在标签之后或之前附加一些HTML?
Is there any way to specify that I want to append some HTML after or before a tag?
提前谢谢.
推荐答案
AFAIK仅靠 AjaxOptions
类的属性无法实现这种行为.一种方法是订阅 OnSuccess
方法并手动进行插入:
AFAIK there is no way to achieve such behavior with only properties of the AjaxOptions
class. One way would be to subscribe for the OnSuccess
method and do the insertion manually:
@Ajax.ActionLink("click me", "someAction", new AjaxOptions { OnSuccess = "success" })
和成功
函数:
<script type="text/javascript">
function success(result) {
$('table').after('th').append(result);
}
</script>
或如果您使用的是MicrosoftAjax,则需要调用 get_data
方法以从ajax调用中获取返回的结果:
or if you are using MicrosoftAjax you need to call the get_data
method to fetch the returned result from the ajax call:
function success(result) {
$('tableid').after('th').append(result.get_data());
}
这篇关于Ajax.ActionLink插入表头之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!