########## List model ############## class window.List show_number: 3 constructor: (list_data, show_number, model, tracker_id)-> @list = [] @show_number = show_number if show_number @model = model @tracker_elem = $("") this.setList(list_data) getList: -> @list.slice(0, @show_number) # use this method to set a new list setList: (list_info)-> @list = [] this.loadList(list_info) @tracker_elem.change() setShowNumber: (num)-> @show_number = num @tracker_elem.change() # meant for internal use. use setList to set the list with info loadList: (list_info)-> return unless list_info list = @list model = @model $.each( list_info, (index, data)-> list.push(new model(data, index)) )