hailwood / jQuery-Tagit

The Jquery Tagit Plugin transforms an html unordered list into a unique tagging plugin.
264 stars 109 forks source link

Making the current input value an object property by the blur handler #10

Closed misja closed 13 years ago

misja commented 13 years ago

Making the current input value an object property when the blur handler is triggered. This way the value is available to any other handlers for processing before the timer defined in the blur handler does, for example on form submit.

The issue I had is that the current value will not get set on form submit because of the timer not completing the _addTag call. With the last value as an object property I can now do the following on submit button click:

_init: function() {
    var self = this;

    $(document).ready(function(){
        $(self.element).closest('form').find(':submit').click(function() {
            if (self.currentValue) {
                self._addTag(self.currentValue);
            }
            self.currentValue = '';
            return true;
        });
    });
},