= form.send field.view_helper, field.method_name, field.html_attributes

- tag_suggestions(field, :length => 5, :order => { :count => :desc }).each do |tag|
  = link_to tag, '#', :class => 'tag_suggestion', :data => { :input_id => form.dom_id(field) }

:javascript
  jQuery(function(){
    var input_id = '#{form.dom_id(field)}'
    $('.tag_suggestion[data-input-id=' + input_id + ']').click(function(event){
      var tag_list, current_values, new_values, tag;
      tag_list = $(this).siblings('input#' + input_id);
      // Get the current values by splitting on a comma and stripping whitespace.
      current_values = jQuery.map(tag_list.val().split(','), function(val){ return jQuery.trim(val) });
      tag = $(this).text();
      // Remove the current tag, if present.
      new_values = jQuery.grep(current_values, function(n) {
        return jQuery.trim(n) != tag
      });
      // Add the current tag, unless we've altered the values already.
      if (new_values.length == current_values.length) {
        new_values[new_values.length] = tag
      }
      tag_list.val(new_values.join(', '));

      return false;
    });
  });

%style
  :sass
    .tag_suggestion
      color: #777
      border-bottom: 1px dotted #b94a48
      &:hover
        color: #aaa
        border-bottom: 1px dotted #953b39
        text-decoration: none

= form.send field.view_helper, field.method_name, field.html_attributes

- tag_suggestions(field, :length => 5, :order => { :count => :desc }).each do |tag|
  = link_to tag, '#', :class => 'tag_suggestion', :data => { :input_id => form.dom_id(field) }

:javascript
  jQuery(function(){
    var input_id = '#{form.dom_id(field)}'
    $('.tag_suggestion[data-input-id=' + input_id + ']').click(function(event){
      var tag_list, new_value;
      tag_list = $(this).siblings('input#' + input_id);

      if (!tag_list.val().match(/\S/)) {
        new_value = this.innerHTML;
      } else {
        new_value = [tag_list.val(), this.innerHTML].join(', ');
      };
      tag_list.val(new_value);

      event.preventDefault();
      return false;
    });
  });

%style
  :sass
    .tag_suggestion
      color: #777
      border-bottom: 1px dotted #b94a48
      &:hover
        color: #aaa
        border-bottom: 1px dotted #953b39
        text-decoration: none

Revert "Suggestion links toggle tags, instead of just adding them."
Revert "Suggestion links toggle tags, instead of just adding them."

This reverts commit 19df72d7f87f9538ef28bbd06f312f169bf945c8.
