Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: marcuswestin/tags.js
base: 4a1c7fc0da
...
head fork: marcuswestin/tags.js
compare: e26c0eb62e
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 10 additions and 19 deletions.
  1. +10 −19 list.js
29 list.js
View
@@ -30,31 +30,22 @@ function list(className, opts) {
}
function addItems(newItems, addOpts, appendOrPrepend) {
- if (typeof newItems == 'undefined') { return }
- if (!$.isArray(newItems)) { newItems = [newItems] }
- if (newItems.length == 0) { return renderEmpty() }
addOpts = tags.options(addOpts, {
updateItems:false
})
+ if (typeof newItems == 'undefined') { return }
+ if (!$.isArray(newItems)) { newItems = [newItems] }
+ if (newItems.length == 0) { return renderEmpty() }
if (isEmpty && opts.renderEmpty) { $tag.empty() } // Remove previous content from renderEmpty
- var count = 0
- for (var i=0; i<newItems.length; i++) {
- appendItem(newItems[i], addOpts, appendOrPrepend)
- count++
- }
isEmpty = false
- return { newItems:count }
- }
-
- function appendItem(item, addOpts, appendOrPrepend) {
- var id = getItemId(item)
- if (data[id]) {
- if (!addOpts.updateItems) {
- return
+ appendOrPrepend.call($tag, $.map(newItems, function(item) {
+ var id = getItemId(item)
+ if (data[id]) {
+ if (!addOpts.updateItems) { return null }
+ $tag.find('#'+id).remove()
}
- $tag.find('#'+id).remove()
- }
- appendOrPrepend.call($tag, renderListItem(item))
+ return renderListItem(item)
+ }))
}
var getItemId = function(item) { return 'tags-list-item-'+opts.getItemId(item) }

No commit comments for this range

Something went wrong with that request. Please try again.