This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addAll: -> | |
@ticketList.each @addOne |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addOne: (ticket) -> | |
@$('table').append SB.Utils.renderTemplate("tickets/summary")(ticket.toJSON()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SB.Views.TicketList = Backbone.View.extend( | |
... | |
initialize: -> | |
$(@el).html(SB.Utils.renderTemplate("tickets/ticket_list")()) | |
_.bindAll this, 'addOne', 'addAll' | |
... | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SB.Views.TicketList = Backbone.View.extend( | |
tagName: "div" | |
className: "listing" | |
initialize: -> | |
$(@el).html(SB.Utils.renderTemplate("tickets/ticket_list")()) | |
@ticketList = new SB.Collections.TicketList() | |
@ticketList.on "add", @addOne | |
@ticketList.on "reset", @addAll | |
@ticketList.fetch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SB.Views.Ticket = Backbone.View.extend( | |
initialize: -> | |
@model = @options.model | |
render: -> | |
$(@el).html SB.Utils.renderTemplate('tickets/template')(@model.toJSON()) | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SB.Collections.TicketList = Backbone.Collection.extend( | |
model: SB.Models.Ticket | |
url: "/tickets" | |
name: "tickets" | |
) |