Guest User

Untitled

a guest
Dec 13th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. class MasterCrm.Views.Organization.Index extends Backbone.View
  2.  
  3. initialize: ->
  4. @collection = new MasterCrm.Collections.Users()
  5. @collection.on("reset change", @render_collection, this)
  6. @collection.on "add", @append_element, this
  7. $.fancybox.showActivity()
  8. @collection.fetch()
  9. @render()
  10.  
  11. initialize_view: ->
  12. @$("#add_user").unbind("click").click =>
  13. new MasterCrm.Views.Organization.NewUser model: new MasterCrm.Models.User(), collection: @collection
  14. return false
  15.  
  16. append_element: (el) ->
  17. new MasterCrm.Views.Organization.User el: @$("ul"), model: el
  18.  
  19. render_collection: ->
  20. @$("ul").html ""
  21. @collection.each (user) => new MasterCrm.Views.Organization.User({el: @$("ul"), model: user})
  22. $.fancybox.hideActivity()
  23.  
  24. render: ->
  25. that = this
  26. @template = _.template $("#organization_index").html(), {}
  27. $(@el).html @template
  28. @initialize_view()
  29. this
Add Comment
Please, Sign In to add comment