mirror of
https://github.com/fergalmoran/dss.git
synced 2026-03-29 17:05:04 +00:00
42 lines
1.2 KiB
CoffeeScript
Executable File
42 lines
1.2 KiB
CoffeeScript
Executable File
define ['jquery', 'marionette', 'models/user/userCollection', 'views/user/userItemView', 'text!/tpl/UserListView'],
|
|
($, Marionette, UserCollection, UserItemView, Template) ->
|
|
class UserListView extends Marionette.CompositeView
|
|
|
|
template: _.template(Template)
|
|
events:
|
|
"keyup #search-text": "doSearch"
|
|
|
|
ui:
|
|
searchText: "#search-text"
|
|
|
|
className: "row"
|
|
itemView: UserItemView
|
|
itemViewContainer: "#user-table"
|
|
initialize: (options) =>
|
|
console.log "UserListView: initialize"
|
|
@collection = new UserCollection()
|
|
@_fetchCollection(options)
|
|
return
|
|
|
|
_fetchCollection: (options) =>
|
|
@collection.fetch(
|
|
data: options
|
|
success: =>
|
|
console.log("UserListView: Collection fetched")
|
|
return
|
|
)
|
|
|
|
doSearch: =>
|
|
console.log("UserListView: doSearch")
|
|
query = @ui.searchText.val()
|
|
if (query)
|
|
@_fetchCollection
|
|
q: query
|
|
else
|
|
@_fetchCollection @options
|
|
|
|
onRender: ->
|
|
window.scrollTo 0, 0
|
|
|
|
UserListView
|