-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Hello there!
I had this problem (Dogfalo/materialize#1440), but the trick proposed wasn't enough (thanks to simple form, the 'ids' and 'for' attributes were already filled).
I finally figured out it was because I had several modals with several forms (ex: edit_task_1 ; edit_task_2, etc) and the 'id' of inputs and the attribute 'for' of the labels where the same in the forms (task_user_ids for all of them) and that's why they could not be checked.
I ended up doing something like this:
// In my shared.js.coffee
// Fix for simple form + materialize checkboxes in several modals
$('p.checkbox').each () ->
form_id = $(this).closest('form').attr('id')
input = $(this).children('input')
label = $(this).children('label')
input_value = input.val()
current_input_id = input.attr('id')
new_name = "#{form_id}_#{current_input_id}_#{input_value}"
$(input).attr('id', new_name)
$(label).attr('for', new_name)
Hope it can help someone in the future! :) Would be perfect if we could have it in this gem too! :)
Thanks!
Metadata
Metadata
Assignees
Labels
No labels