Guest User

Untitled

a guest
Apr 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. def add_new_procedure_fields(name)
  2. link_to_function name do |page|
  3. page << "index = $$('#procedures .procedure').length;"
  4.  
  5. page.insert_html :bottom, :procedures, :partial => 'actual_procedures/form', :locals => {:add_auto_complete => false}
  6. page << "stale = $$('#procedures .procedure').last();"
  7. page << "fresh = stale.innerHTML.gsub('_0', '_' + index).gsub('[0]', '[' + index + ']');"
  8. page << "stale.update(fresh);"
  9.  
  10. function = "new Ajax.Autocompleter("
  11. function << "'terms_' + index, "
  12. function << "'terms_' + index + '_auto_complete', "
  13. function << "'#{auto_complete_procedures_path}', "
  14. function << "{paramName: 'terms', parameters:'authenticity_token=' + encodeURIComponent('89f0d5534cf4bc7a852e2ae2a41d07682ae68023'), select:'procedure_name'})"
  15.  
  16. page << function
  17. end
  18. end
Add Comment
Please, Sign In to add comment