Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. def update_select_box(target_dom_id, collection, options={})
  2. # Set the default options
  3. options[:text] ||= 'name'
  4. options[:value] ||= 'id'
  5. options[:include_blank] ||= true
  6. pre = options[:include_blank] ? [['','']] : []
  7.  
  8. out = "update_select_options($('" << target_dom_id.to_s << "'), "
  9. out << "#{(pre + collection.collect { |c| [c.send(h(options[:text])), c.send(h(options[:value]))]}).to_json}" << ")"
  10. end
Add Comment
Please, Sign In to add comment