开发者

Rails dynamic form updating

G'day guys,

I have a bit of an odd request for a dynamic form. Firstly I'm working with Rails 1.2.6 so I've monkey patched a fair bit of the latter functionality into the app (It's working in an embedded environment on top of a lot of custom code so upgrading it to rails 2 or even (gasp) rails 3 is not an option for the current release I'm working on).

Basically I have a form for a group of individuals that needs to be modified based on the individuals that are added to it. So you have a name for the group and then a list of people that may or may not be added to the group. These people then m开发者_运维技巧ay have notifications turned on or turned off, I want to dynamically reload the group based on clicking a checkbox to add a person to the group or not, but do it in a way that it won't break other browsers or the overall form. The way I was thinking of doing it was using the jquery form element to add those user objects to the form object and then return a partial that's rendered inline at the bottom part of the form to enable whether users of that group receive group notifications.

Is there a simpler way or am I better off just using rendered partials that are inserted into the DOM and then having the form submit in the normal way after the users have made their selections?


It appears that returning partials through a JS handler in a controller is the most efficient way of doing this and one that works cross-platform.

Effectively set up actions in your controllers that will return partials based on objects returned to them, as you would do a remote form or other.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜