ruby on rails - Rendering an edit partial form with bootstrap modals -


i working on ruby on rails project has similar functionalities dropbox. gems use:

  1. carrierwave: uploading files
  2. acts_as_tree: folder directory
  3. slim: cleaner html
  4. bootstrap 4

i trying incorporate bootstrap modals renders edit form users able edit file_name attribute have in model.

- @documents.each |document|   = link_to document.file.filename, document.file.url   b = document.file_name   = number_to_human_size(document.file.size, :precision => 2)   = document.content_type   = document.updated_at   = link_to "download", document.file.url   #renamebutton.button.btn.btn-primary data-toggle="modal" data-target="#renamemodal" rename   #renamemodal.modal.fade tabindex="=1" role="dialog" aria-labelledby="examplemodallabel" aria-hidden="true"     .modal-dialog role="document"       .modal-content         .modal-header           #examplemodallabel.h5.modal-title rename folder           button.close data-dismiss="modal" aria-label="close"             span aria-hidden="true" ×         .modal-body           = form_for document |f|             = f.label :name             = f.text_field :file_name             = f.submit         .modal-footer           button.btn.btn-outline-success data-dismiss="modal" aria-hidden="true" close           button.btn.btn-outline-danger save changes   = link_to "delete", document, :confirm => 'are sure?', :method => :delete 

the problem have whenever click on of "rename" button, rendered edit form inside modal point first file entry instead of selected one.

i think having modal inside do-loop causes issue.

is there way around this?

the issue using same data-target rename buttom click open model , every modal have same id

try using iterator each id

data-target="#renamemodal#{index}" 

and model id should be:

id: "#renamemodal#{index}" 

i dont know slim syntax use please use slim syntax. basic bootstrap concept.

hope helps...


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -