The attach method of the behavior is called every time behaviors are attached. This causes three issues:

1) The uniqueness variable is repeated initialized. This should be addressed by the X = X || init_val pattern. It should probably also be explicitly declared in the outer scope (which should be a closure).
2) The title field's keyup method is repeatedly bound. This should be extended with the .once() pattern.
3) The tags field's blur method is repeated bound. Same as 2).

Additionally, uniqueness is in the global scope. The entire module should be enclosed in a $ closure, which would also allow all the jQuery references to be changed to the standard $ identifier and keep the global variables out of the global scope.

Comments

danchadwick’s picture

Because encapsulating the file in a closure indents the whole file, I have included both a normal patch (intended to be applied) and one with -w (ignoring whitespace) so you can see the actual changes (other than indentation).

I have confirmed that this works both after the initial page load and when Drupal.attachBehaviors() is called.

danchadwick’s picture

Status: Active » Needs review
bforchhammer’s picture

Status: Needs review » Fixed

Awesome, thanks! Cleaned up some whitespace issues and committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.