Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Fix listview undefined behaviour #101

Merged
merged 2 commits into from
Dec 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/autocomplete/autocompletecontroller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ module.exports = class KDAutoCompleteController extends KDViewController
inexactMatches.push datum

if (@dropdownPrefix.length >= minSuggestionLength) and allowNewSuggestions and not exactMatches.length
@dropdown.getListView().addItem @getNoItemFoundView()
@dropdown.getListView().addItemView @getNoItemFoundView()

data = exactMatches.concat inexactMatches
@dropdown.instantiateListItems data
Expand Down Expand Up @@ -385,7 +385,7 @@ module.exports = class KDAutoCompleteController extends KDViewController
list = @dropdown.getListView()

@dropdown.removeAllItems()
list.addItem new fetchingItemClass {}, {}
list.addItemView new fetchingItemClass {}, {}
@showDropdown()

getNoItemFoundView: (suggestion) ->
Expand All @@ -403,7 +403,7 @@ module.exports = class KDAutoCompleteController extends KDViewController

noItemFoundView = @getNoItemFoundView()
@dropdown.removeAllItems()
@dropdown.getListView().addItem noItemFoundView
@dropdown.getListView().addItemView noItemFoundView
@showDropdown()

destroy:->
Expand Down
10 changes: 10 additions & 0 deletions src/components/list/listview.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ module.exports = class KDListView extends KDView
return sanitizedIndex


addItemView: (itemInstance, index) ->

index = @sanitizeIndex index

@insertItemAtIndex itemInstance, index

return itemInstance


addItem: (itemData, index) ->

index = @sanitizeIndex index
Expand Down Expand Up @@ -235,6 +244,7 @@ module.exports = class KDListView extends KDView
else @isScrollAtBottom scrollView
else no


isScrollAtBottom: (scrollView) ->

slidingView = scrollView.find('> .kdview')[0]
Expand Down