如何在MVC5中动态添加输入组 [英] How to dinamicly add input groups in MVC5

查看:78
本文介绍了如何在MVC5中动态添加输入组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC 5中实现类的列表集合时遇到问题.我知道在MVC的早期版本中有解决方案或示例,例如在小提琴中的类似内容.

是否有更新的示例或博客文章描述了这种情况,因为我似乎无法找到它.

谢谢.
B

Hi, Im having a problem implementing a list collection of a class in MVC 5. I know there are solutions or examples how to do this in earlier versions of MVC like this one in this blog post but I cannot belive that in the next three versions of MVC this wasnt implemented more gracefuly or elegantly.

I have a model class that consists of several properties and one of them is a list collection of another entity. In my form I want to let the user set the number of fields and and then render them with correct id''s so that the model binder will recognize that this is the data for the list collection. Something like in this Fiddle.

Is there a newer example or blog post describing this scenario becouse I can not seem to be able to find it.

Thank you.
B

推荐答案

您好,我希望这是您想要的.

为您要添加的控件创建一个小模型,单击任何按钮即可将其填充到div中,然后通过ajax或jQuery post方法将其与空白模型属性一起加载回去.

并且在主模型中获取子模型的列表

[
Hi I hope this is what you are looking for.

take a small model for your controls which you want to populate in a div on any button click and load it back with blank model properties through ajax or jQuery post methods.

And In main model take the list for child model

[ a small demo you can see in this blog]


:-)


这篇关于如何在MVC5中动态添加输入组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆