Guest User

Untitled

a guest
May 20th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. module PropertiesHelper
  2. def property_form_javascript
  3. html = '
  4. $("#property_kind").change(function(){
  5. var id = parseInt(this.value)
  6. var html = ""
  7. for(var i=0 ; i<categories[id].length ; i++)
  8. html += "<option value=\"" + categories[id][i].id + "\">" + categories[id][i].name + "</option>\n"
  9. $("#property_category_id").html(html)
  10. })
  11.  
  12. var categories = []
  13. '
  14. Property::KINDS.each_pair do |name, id|
  15. categories = Category.find_all_by_kind(id, :order => 'name asc').map { |c|
  16. "{id: #{c.id}, name: '#{c.name}'}"
  17. }.join(", ")
  18. html << "categories[#{id}] = [#{categories}];\n"
  19. end
  20. html
  21. end
  22.  
  23. end
Add Comment
Please, Sign In to add comment