Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: marcuswestin/tags.js
base: e26c0eb62e
...
head fork: marcuswestin/tags.js
compare: 2b9bd6d9b3
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 7 additions and 5 deletions.
  1. +7 −5 list.js
View
12 list.js
@@ -21,7 +21,7 @@ function list(className, opts) {
var data = {}
var $tag
- var isEmpty = false
+ var isEmpty
function renderListItem(item) {
var id = getItemId(item)
@@ -35,7 +35,7 @@ function list(className, opts) {
})
if (typeof newItems == 'undefined') { return }
if (!$.isArray(newItems)) { newItems = [newItems] }
- if (newItems.length == 0) { return renderEmpty() }
+ if (newItems.length == 0) { return }
if (isEmpty && opts.renderEmpty) { $tag.empty() } // Remove previous content from renderEmpty
isEmpty = false
appendOrPrepend.call($tag, $.map(newItems, function(item) {
@@ -54,6 +54,7 @@ function list(className, opts) {
list.init($tag, selectEl)
var items = opts.items || []
if (items.length) {
+ isEmpty = false
$tag.append($.map(items, renderListItem))
} else {
renderEmpty()
@@ -92,13 +93,14 @@ function list(className, opts) {
}
return this
}
+ result.isEmpty = function() { return isEmpty }
result.find = function(selector) { return $tag.find(selector) }
function selectEl(el) {
var id = el.getAttribute('id')
- var result = data[id]
- if (result == null) { return }
- opts.onSelect.call(el, result)
+ var item = data[id]
+ if (item == null) { return }
+ opts.onSelect.call(el, item)
}
return result

No commit comments for this range

Something went wrong with that request. Please try again.