Simple Form - Rails 4 - editing

Mel

I am trying to use simple form with my rails 4 app.

I have a project model, which has a scope model. Scope belongs to project. I have a third model, called participant, which belongs to scope. Scope accepts nested attributes for participant and project accepts nested attributes for scope.

When I create a new project, my form has partials which are nested forms for each of scope and participant. In my scope form, I ask whether this project involves participants. If the answer is true, I use JS form helper to show a hidden partial which contains the participant form.

If, after creating the project, I want to edit it, the edit function returns me to the project form, which shows the checkbox for participant (as true), but hides the participant form.

My question is, if the participant checkbox is checked as true, then the participant form nested in the project form should be revealed. My JS form helper hides this form until the box is checked as true, and this works fine in the create mode, but I need to un check the participant box in the scope form and re-check it in order to reveal the participant form - so that i can edit those fields.

Do you know how to reveal the participant form if the scope question asking about participation is true without unchecking and rechecking the form?

My code is as follows:

In my JS form helper, I have (which hides the participant nested form unless the scope question asking if participation is sought is true):

$(document).on 'change', '#' + inString +  '_scope_attributes_if_participant', ()->
  if $('#' + inString +  '_scope_attributes_if_participant').is(':checked')
    $('#participationrequest').show()
  else
    $('#participationrequest').hide()

In my scope form, I have:

    <%= s_all.input :if_participant, :as => :boolean, :label => false, inline_label: 'Public participants or volunteers' %>

Thank you

Mel
if $('#' + inString +  '_scope_attributes_if_participant').is(':checked')
  $('#participationrequest').show()
else
  $('#participationrequest').hide()
$(document).on 'change', '#' + inString +  '_scope_attributes_if_participant', ()->
  if $('#' + inString +  '_scope_attributes_if_participant').is(':checked')
    $('#participationrequest').show()
  else
    $('#participationrequest').hide()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Display selected option when editing a form (Rails 4)

From Dev

Building a simple calculator form in Rails 4

From Dev

Rails 4 with Reform GEM and simple_form

From Dev

rails 4 simple form currency tag

From Dev

rails 4 simple form currency tag

From Dev

Associated model and simple_form in Rails 4

From Dev

Rails 4 with Simple Form - CSS problems

From Dev

Rails 4 Nested Forms Simple_form_for & simple_field_for

From Dev

Rails 4, Bootstrap 3, simple_form - form styling not working

From Dev

Rails 4 -Simple Form how to save key and display value

From Dev

Rails 4 - Simple Form - how to get rid of the label

From Dev

Rails 4: Change 'name' attribute of Simple Form input

From Dev

Integrating hstore column with simple_form in Rails 4

From Dev

jQuery Tags-Input with Rails4 / Simple_form

From Dev

Creating multiple nested forms using simple_form and rails 4

From Dev

Ruby on Rails 4 - simple_form multiple select input

From Dev

Rails 4 action routes with simple_form and shallow nested resources

From Dev

rails 4 simple_form as: hidden don't send

From Dev

Rails4: How to apply Bootstrap to simple_nested_form_for

From Dev

Devise polymorphic association nested attributes with simple form using rails 4

From Dev

jQuery Tags-Input with Rails4 / Simple_form

From Dev

Integrating hstore column with simple_form in Rails 4

From Dev

Integrate Bootstrap 3 into simple_form using haml on Rails 4

From Dev

Rails 4 -Simple Form how to save key and display value

From Dev

How to create select for enum attribute in Rails 4 with simple Form

From Dev

Rails 4 - Simple Form - Jquery - How to add a class to an option in a selectbox

From Dev

Rails 4: show uploaded image when editing form - getting undefined local variable or method

From Dev

Rails4: creating and editing an object, through its association to another object, to a form_for helper

From Dev

Rails Devise & Simple Form

Related Related

  1. 1

    Display selected option when editing a form (Rails 4)

  2. 2

    Building a simple calculator form in Rails 4

  3. 3

    Rails 4 with Reform GEM and simple_form

  4. 4

    rails 4 simple form currency tag

  5. 5

    rails 4 simple form currency tag

  6. 6

    Associated model and simple_form in Rails 4

  7. 7

    Rails 4 with Simple Form - CSS problems

  8. 8

    Rails 4 Nested Forms Simple_form_for & simple_field_for

  9. 9

    Rails 4, Bootstrap 3, simple_form - form styling not working

  10. 10

    Rails 4 -Simple Form how to save key and display value

  11. 11

    Rails 4 - Simple Form - how to get rid of the label

  12. 12

    Rails 4: Change 'name' attribute of Simple Form input

  13. 13

    Integrating hstore column with simple_form in Rails 4

  14. 14

    jQuery Tags-Input with Rails4 / Simple_form

  15. 15

    Creating multiple nested forms using simple_form and rails 4

  16. 16

    Ruby on Rails 4 - simple_form multiple select input

  17. 17

    Rails 4 action routes with simple_form and shallow nested resources

  18. 18

    rails 4 simple_form as: hidden don't send

  19. 19

    Rails4: How to apply Bootstrap to simple_nested_form_for

  20. 20

    Devise polymorphic association nested attributes with simple form using rails 4

  21. 21

    jQuery Tags-Input with Rails4 / Simple_form

  22. 22

    Integrating hstore column with simple_form in Rails 4

  23. 23

    Integrate Bootstrap 3 into simple_form using haml on Rails 4

  24. 24

    Rails 4 -Simple Form how to save key and display value

  25. 25

    How to create select for enum attribute in Rails 4 with simple Form

  26. 26

    Rails 4 - Simple Form - Jquery - How to add a class to an option in a selectbox

  27. 27

    Rails 4: show uploaded image when editing form - getting undefined local variable or method

  28. 28

    Rails4: creating and editing an object, through its association to another object, to a form_for helper

  29. 29

    Rails Devise & Simple Form

HotTag

Archive