我明白使用 jEditable (http://www.appelsiini.net/projects/jeditable http://www.appelsiini.net/projects/jeditable)您可以进行就地编辑并将更改的信息发布到 URL。
我的 ASP.NET MVC 视图显示了一堆模型信息,我希望这些信息可以就地编辑。目前,我有两个视图 - 一个文本表示形式和一个编辑视图,其中表单完全被发布,然后我的控制器操作将整个对象(从表单元素名称组装)作为参数,更新对象并返回文本-仅视图。
但是,当我切换到 jEditable 时,我只会使用文本视图并一次发布一个项目,而不是整个对象。我如何构建一个单一的控制器操作来获取 jEditable 正在发布的内容,然后将其放入我的对象的适当属性中?
有一些还不错示例代码在这里 http://amrelsehemy.net/post/2008/10/05/jBlogMvc-part-2-editing-deleting-paging-posts-rss-feeds.aspx:
$("#myTextBox").editable('<%=Url.Action("UpdateSettings","Admin") %>', {
submit: 'ok',
cancel: 'cancel',
cssclass: 'editable',
width: '99%',
placeholder: 'emtpy',
indicator: "<img src='../../Content/img/indicator.gif'/>"
});
[AcceptVerbs("POST")]
public ActionResult UpdateSettings(string id, string value)
{
// This highly-specific example is from the original coder's blog system,
// but you can substitute your own code here. I assume you can pick out
// which text field it is from the id.
foreach (var item in this.GetType().GetProperties())
{
if (item.Name.ToLower().Equals(id, StringComparison.InvariantCultureIgnoreCase))
item.SetValue(Config.Instance, value, null);
}
return Content(value);
}
您可能还需要这个:
http://noahblu.wordpress.com/2009/06/17/jeditable-note-dont-return-json-and-how-to-return-strings-from-asp-net-mvc-actions/ http://noahblu.wordpress.com/2009/06/17/jeditable-note-dont-return-json-and-how-to-return-strings-from-asp-net-mvc-actions/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)