Sha256: 7b817c026038c0fbe30f1937a9664ee5eed90f3dc53d268026b10f59df929fc0

Contents?: true

Size: 783 Bytes

Versions: 72

Compression:

Stored size: 783 Bytes

Contents

var tags = tags || {
  init: function() {
    $('input[data-tagbox]').udongo_tagbox({
      on_add: tags.add,
      on_remove: tags.remove
    });
  },

  add: function(tag, input) {
    tags.call('POST', tag, input);
  },

  remove: function(tag, input) {
    tags.call('DELETE', tag, input);
  },

  call: function(type, tag, input) {
    if(typeof type == 'undefined') return;

    $.ajax({
      url: input.data('base-path'),
      data: {
        locale: input.data('locale'),
        taggable_type: input.data('type'),
        taggable_id: input.data('id'),
        tag: tag
      },
      type: type
    }).done(function(data){
      if(type == 'POST' && !data.valid) {
        input.tagit('removeTagByLabel', data.tag);
      }
    });
  }
};

$(function(){ tags.init(); });

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
udongo-7.9.0 app/assets/javascripts/backend/tags.js
udongo-7.8.1 app/assets/javascripts/backend/tags.js
udongo-7.8.0 app/assets/javascripts/backend/tags.js
udongo-7.7.2 app/assets/javascripts/backend/tags.js
udongo-7.7.1 app/assets/javascripts/backend/tags.js
udongo-7.7.0 app/assets/javascripts/backend/tags.js
udongo-7.6.2 app/assets/javascripts/backend/tags.js
udongo-7.6.1 app/assets/javascripts/backend/tags.js
udongo-7.6.0 app/assets/javascripts/backend/tags.js
udongo-7.5.1 app/assets/javascripts/backend/tags.js
udongo-7.5.0 app/assets/javascripts/backend/tags.js
udongo-7.4.2 app/assets/javascripts/backend/tags.js
udongo-7.4.1 app/assets/javascripts/backend/tags.js
udongo-7.4.0 app/assets/javascripts/backend/tags.js
udongo-7.3.5 app/assets/javascripts/backend/tags.js
udongo-7.3.4 app/assets/javascripts/backend/tags.js
udongo-7.3.3 app/assets/javascripts/backend/tags.js
udongo-7.3.2 app/assets/javascripts/backend/tags.js
udongo-7.3.1 app/assets/javascripts/backend/tags.js
udongo-7.2.1 app/assets/javascripts/backend/tags.js