views:

34

answers:

2

A lot of sites offer the ability to edit lists of items inline as well as allowing multiple items to be selected via checkboxes and have an action performed all at once e.g. delete, mark as spam etc.

But how do you implement this without violating html rules. I need one form for the checkboxes with individual submit_tags for the mass actions. But after a user clicks on an item in the list, another form via Ajax will be inserted within the checkbox form.

How do I avoid doing this? I'm using rails and jQuery.

A: 

If I don't misunderstand your question, you need not wrap the items in (checkboxes, buttons, etc) in a form.

In your scenario I would suggest you create a separate hidden form that is out of your list/data grid. This won't wrap any of your grid items. You populate the hidden form having some hidden variable with the user selected record identifiers and action you want to perform with help of javascript on button click.

You can have such multiple hidden forms that would be called and submitted through javascript to perform a desired action.

Penuel
A: 

I think you want to post multiple form(nest) separately. as you use "submit_tag",when click it, all form will submit in default; try this: specify different id for those form,and then use "button_to_function" replace "submit_tag" example: <%=button_to_functon "Submit","$('#form_id').submit();return false;"%>

hope these can help you!

psjscs