Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

update single input before triggering onTagRemove #4

Closed
wants to merge 1 commit into from

2 participants

@jpalmucci

Send the onTagRemove event after the single input field has been updated so its easy to grab the new set of tags as a set.

@aehlke
Owner

I don't think I'm going to pull this, sorry -- in the docs, onTagRemoved has been used to mean that a tag is about to be removed, not that it already has.

I can see that it'd be useful to be able to hook into both the before and after events. So I think a better idea would be to deprecate this event, and add two new events with clearer names -- something like beforeTagRemoved and afterTagRemoved (perhaps there's a more idiomatic naming scheme for jQuery stuff than this).

The events are inconsistent in your master. onTagRemoved is fired before the field is updated and onTagAdded is fired after. My version is consistent. Sure you don't want to pull it?

Alternatively, how about adding 2 more custom parameters to the event. The field values before and after the update. (I'll do this if you agree its a good idea.)

@aehlke
Owner

Ah, the onTagAdded behavior is a bug then. Let me see if that's always been the behavior or not before changing the code or the docs... I recently became the maintainer of this widget, so there are a lot of users of the old version that I'd like to help upgrade without changing much of the API on them.

Because of the legacy support, I'd rather just deprecate this and add 2 clearer events. I'd rather keep them separate than use a data field to specify before/after, since it's potentially a little confusing to generate 2 "onTagRemoved" events per tag removal.

@aehlke
Owner

Please see this new issue: #5

@aehlke aehlke closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 23, 2011
  1. @jpalmucci

    Send the onTagRemove event after the single input field has been upda…

    jpalmucci authored
    …ted so its easy to grab the new set of tags as a set.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 js/tag-it.js
View
5 js/tag-it.js
@@ -345,8 +345,6 @@
tag = $(tag);
- this._trigger('onTagRemoved', null, tag);
-
if (this.options.singleField) {
var tags = this.assignedTags();
var removedTagLabel = this.tagLabel(tag);
@@ -355,6 +353,9 @@
});
this._updateSingleTagsField(tags);
}
+
+ this._trigger('onTagRemoved', null, tag);
+
// Animate the removal.
if (animate) {
tag.fadeOut('fast').hide('blind', {direction: 'horizontal'}, 'fast', function(){
Something went wrong with that request. Please try again.