使用jEditable在ASP.NET MVC(发帖) [英] Using jEditable with ASP.NET MVC (POSTing)
问题描述
据我所知,有jEditable( http://www.appelsiini.net/projects/jeditable),你可以做就地编辑和后期更改信息的URL。
I understand that with jEditable (http://www.appelsiini.net/projects/jeditable) you can do in-place editing and POST the changed information to a URL.
我的ASP.NET MVC视图显示了一堆,我想作就地编辑模式的信息。目前,我有两个观点 - 一个文本重新presentation和一个编辑视图中的窗体完全公布,并随后我的控制器动作发生的整个对象(从表单元素的名称组合)作为参数,更新的对象,返回文本浏览。
My ASP.NET MVC view is displaying a bunch of Model information which I'd like to make in-place editable. Currently, I have two views - one text representation and one edit view in which a form is entirely POSTed and then my controller action takes the entire object (assembled from the form element names) as a parameter, updating the object and returning to the text-only view.
然而,当我切换到jEditable我只会用文字查看和发表的单个项目的时间,而不是整个对象。我怎么能建立一个单一的控制器动作,可以采取什么jEditable被张贴和然后把它放到我的对象的合适的属性?
However, when I switch to jEditable I would only use the text view and POST a single item at a time, and not the entire object. How could I build a single controller action that can take what jEditable is POSTing and then put it into the appropriate property of my object?
推荐答案
有一些pretty的好<一href="http://amrelsehemy.net/post/2008/10/05/jBlogMvc-part-2-editing-deleting-paging-posts-rss-feeds.aspx"相对=nofollow>样本code这里:
There's some pretty good sample code here:
$("#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);
}
您可能还需要这样的:
<一href="http://noahblu.word$p$pss.com/2009/06/17/jeditable-note-dont-return-json-and-how-to-return-strings-from-asp-net-mvc-actions/" rel="nofollow">http://noahblu.word$p$pss.com/2009/06/17/jeditable-note-dont-return-json-and-how-to-return-strings-from-asp-net-mvc-actions/
You might also need this:
http://noahblu.wordpress.com/2009/06/17/jeditable-note-dont-return-json-and-how-to-return-strings-from-asp-net-mvc-actions/
这篇关于使用jEditable在ASP.NET MVC(发帖)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!