Skip to content

Commit

Permalink
fix to issue xoxco#28
Browse files Browse the repository at this point in the history
xoxco#28
onChange now receives the tag added or removed.
  • Loading branch information
Ben Brown committed Nov 15, 2011
1 parent 5437401 commit 49fc5f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jquery.tagsinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
{
var i = tagslist.length;
var f = tags_callbacks[id]['onChange'];
f.call(this, $(this), tagslist[i]);
f.call(this, $(this), tagslist[i-1]);
}
}

Expand Down
8 changes: 7 additions & 1 deletion test.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
alert("Removed a tag: " + tag);
}

function onChangeTag(input,tag) {
alert("Changed a tag: " + tag);
}

$(function() {

$('#tags_1').tagsInput();
$('#tags_2').tagsInput({
onChange: function(elem, elem_tags)
Expand All @@ -43,8 +48,9 @@
autocomplete_url:'test/fake_json_endpoint.html' // jquery ui autocomplete requires a json endpoint
});


// Uncomment this line to see the callback functions in action
// $('input.tags').tagsInput({onAddTag:onAddTag,onRemoveTag:onRemoveTag});
// $('input.tags').tagsInput({onAddTag:onAddTag,onRemoveTag:onRemoveTag,onChange: onChangeTag});

// Uncomment this line to see an input with no interface for adding new tags.
// $('input.tags').tagsInput({interactive:false});
Expand Down

0 comments on commit 49fc5f3

Please sign in to comment.