Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update_select_box(target_dom_id, collection, options={})
- # Set the default options
- options[:text] ||= 'name'
- options[:value] ||= 'id'
- options[:include_blank] ||= true
- pre = options[:include_blank] ? [['','']] : []
- out = "update_select_options($('" << target_dom_id.to_s << "'), "
- out << "#{(pre + collection.collect { |c| [c.send(h(options[:text])), c.send(h(options[:value]))]}).to_json}" << ")"
- end
Add Comment
Please, Sign In to add comment