Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## in your form.html.haml
- ``` javascript
- $(document).on('click', '.add_an_aol_field', function(){
- $aol_field = $('#aol_selector_template').html();
- $('.aol_fields').append($aol_field);
- });
- $(document).on('click', '.remove_this_aol_field', function(){
- $(this).closest('.aol_id_field').remove();
- });
- ```
- ```haml
- .aols
- .aol_fields
- - @profile.aols.each do |aol|
- = render('aols/aol_dropdown', aol: aol)
- %a.add_an_aol_field add
- %script{type="text" id="aol_selector_template"}
- = render('aols/aol_dropdown')
- ```
- ### params coming into controller
- ```ruby
- params = {
- attorney_profile: {
- aol_ids: [1, 3, 35]
- }
- }
- ```
- ### inside app/views/aols/_aol.html.haml
- ``` haml
- .aol_id_field
- %select{name="attorney_profile[aol_ids][]"}
- - @aols.each do |aol|
- %option{value: aol.id}= aol.name
- %a.remove_this_aol_field X
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement