Guest User

Untitled

a guest
Oct 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. jQuery ->
  2. $ ->
  3. # store investors
  4. company = $('#deal_company_id')
  5. investors = $('#deal_offerings_buyers')
  6. investorsOriginal = investors.find("option")
  7. investors.chosen()
  8. company.chosen()
  9.  
  10. # on load, remove company from options
  11. companyId = company.find(":selected").val()
  12. $('#deal_offerings_buyers option[value="Company:'+companyId+'"]').remove()
  13. investors.trigger("liszt:updated")
  14.  
  15. # when company is changed, rebuilt investor options
  16. company.chosen().change =>
  17.  
  18. # remove company from options
  19. companyId = company.find(":selected").val()
  20. $('#deal_offerings_buyers option[value="Company:'+companyId+'"]').remove()
  21.  
  22. # add remaining
  23. investorsCurrent = investors.find("option")
  24. investorsOriginal.each ->
  25. unless this in investorsCurrent || this.value is "Company:#{companyId}"
  26. investors.append(this)
  27.  
  28. investors.trigger("liszt:updated")
Add Comment
Please, Sign In to add comment