Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MasterCrm.Views.Organization.Index extends Backbone.View
- initialize: ->
- @collection = new MasterCrm.Collections.Users()
- @collection.on("reset change", @render_collection, this)
- @collection.on "add", @append_element, this
- $.fancybox.showActivity()
- @collection.fetch()
- @render()
- initialize_view: ->
- @$("#add_user").unbind("click").click =>
- new MasterCrm.Views.Organization.NewUser model: new MasterCrm.Models.User(), collection: @collection
- return false
- append_element: (el) ->
- new MasterCrm.Views.Organization.User el: @$("ul"), model: el
- render_collection: ->
- @$("ul").html ""
- @collection.each (user) => new MasterCrm.Views.Organization.User({el: @$("ul"), model: user})
- $.fancybox.hideActivity()
- render: ->
- that = this
- @template = _.template $("#organization_index").html(), {}
- $(@el).html @template
- @initialize_view()
- this
Add Comment
Please, Sign In to add comment