在 asp.net mvc 2 中使用 jQuery 在表单发布之前动态构建集合
在我的对象图中,我有一个标准的父+子关系。可以这样说:
Cat.Kittens = new HashSet
当我有一个新猫的表单时,我想在单击“保存”按钮之前添加零只或多只小猫。由于它是一只新猫,我也不想将小猫发布到服务器(即使用 AJAX 等;我只想使用保存按钮将一个大转储发送到服务器)。我正在尝试找出有效的最佳方法,但谷歌的能力不足。一定有人已经这么做了。
我不太关心父猫是否是新的;如果我必须将小猫添加推到编辑表单中,那就这样吧。对我来说,问题是如何在客户端上动态添加多只小猫,然后能够在存储数据之前在控制器中处理集合。
有什么想法吗?好的例子吗? jQuery + asp.net mvc 2 是堆栈。
提前致谢!
In my object graph, I have a standard parent + children relationship. Say something like,
Cat.Kittens = new HashSet<Cat>();
When I have a form for a new Cat, I want to add zero-or-many kittens prior to clicking the save button. Since it's a new Cat, I also don't want to post the kitten to the server yet (i.e. using AJAX or the like; I just want to do one big dump to the server with the save button). I'm trying to figure out the best way to do this with some efficiency but am coming up short on Google. Someone has to have done this already.
I'm less concerned about whether the parent Cat is new or not; if I have to push the kitten addition off to an Edit form, so be it. The issue for me is how to dynamically add multiple kittens on the client and subsequently be able to massage the collection in the controller prior to storing the data.
Any ideas? Good examples? jQuery + asp.net mvc 2 is the stack.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可以用一种形式来完成,我已经这样做了,我将在页面上隐藏一个空白的小猫输入表单,然后当客户说添加另一只小猫时用 jquery 复制它。
控制器是比较困难的地方
Controller
View
It can be done in one form I have done this where I will keep a blank kitten input form hidden on the page then copy it with jquery when the client says add another kitten.
The controller is where it gets a little tougher
Controller
View