mirror of
https://github.com/fergalmoran/dss.git
synced 2026-04-04 11:55:02 +00:00
50 lines
1.6 KiB
CoffeeScript
Executable File
50 lines
1.6 KiB
CoffeeScript
Executable File
define ['jquery', 'marionette', 'models/user/userCollection', 'views/user/userItemView', 'text!/tpl/UserListView',
|
|
'bootpag'],
|
|
($, Marionette, UserCollection, UserItemView, Template) ->
|
|
class UserListView extends Marionette.CompositeView
|
|
|
|
template: _.template(Template)
|
|
events:
|
|
"keyup #search-text": "doSearch"
|
|
|
|
ui:
|
|
searchText: "#search-text"
|
|
|
|
itemView: UserItemView
|
|
itemViewContainer: "#user-table"
|
|
initialize: =>
|
|
console.log "UserListView: initialize"
|
|
@collection = new UserCollection()
|
|
@_fetchCollection(@options)
|
|
return
|
|
|
|
_fetchCollection: (options)=>
|
|
@collection.fetch(
|
|
data: options
|
|
success: =>
|
|
console.log("UserListView: Collection fetched")
|
|
console.log(@collection)
|
|
pag = $("#page-selection").bootpag
|
|
total: @collection.page_count
|
|
|
|
pag.off "page"
|
|
pag.on "page", (event, num) => # page number here
|
|
if num != @collection.page
|
|
console.log "Paginating"
|
|
@collection.page = num # Load next page
|
|
@collection.fetch()
|
|
|
|
return
|
|
)
|
|
return
|
|
|
|
doSearch: =>
|
|
console.log("UserListView: doSearch")
|
|
query = @ui.searchText.val()
|
|
if (query)
|
|
@_fetchCollection
|
|
q: query
|
|
else
|
|
@_fetchCollection @options
|
|
|
|
UserListView |