I have a hidden_field_tag in a form to pass an array of flags (0 or 1) with length @tags. When the page loads, the flags are all 0, but when something happen I want to update one index value, so it's 1 after some trigger action.
So, summing up, in my view I've got something like this:
- @tags.each do |tag|
= hidden_field_tag "tags[]", 0
And in my .js I want to be able to edit one value from that array.
Any ideas of how to do this?
Find the solution:
Changed
- @tags.each do |tag|
= hidden_field_tag "tags[]", 0
To
- @tags.each do |tag|
= hidden_field_tag "tags[]", 0, id: "tag_"+tag.id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.