Giter Site home page Giter Site logo

arondeparon / jquery-tags-input Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xoxco/jquery-tags-input

2.0 2.0 0.0 100 KB

Magically convert a simple text input into a cool tag list with this jQuery plugin.

Home Page: http://xoxco.com/clickable/jquery-tags-input

jquery-tags-input's Introduction

jQuery Tags Input Plugin 1.3

Copyright (c) 2011 XOXCO, Inc

Documentation for this plugin lives here:
http://xoxco.com/clickable/jquery-tags-input

Licensed under the MIT license:
http://www.opensource.org/licenses/mit-license.php

The git repository for this plugin can be found at:
https://github.com/xoxco/jQuery-Tags-Input

[email protected]
------------------------------------------------------

Do you use tags to organize content on your site? 
This plugin will turn your boring tag list into a 
magical input that turns each tag into a style-able 
object with its own delete link. The plugin handles 
all the data - your form just sees a comma-delimited 
list of tags!


Instructions

First, add the Javascript and CSS files to your <head> tag:

<script src="jquery.tagsinput.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.tagsinput.css" />

Create a real input in your form that will contain a comma-separated list of 
tags. You can put any default or existing tags in the value attribute, and 
they'll be handled properly.

<input name="tags" id="tags" value="foo,bar,baz" />

Then, simply call the tagsInput function on any field that should be treated as
a list of tags.

$('#tags').tagsInput();

If you want to use jQuery.autocomplete, you can pass in a parameter with the 
autocomplete url.

$('#tags').tagsInput({
  autocomplete_url:'http://myserver.com/api/autocomplete'
});

You can also send in options to the autocomplete plugin, as described here.

$('#tags').tagsInput({    
  autocomplete_url:'http://myserver.com/api/autocomplete',
  autocomplete:{selectFirst:true,width:'100px',autoFill:true}
});

You can add and remove tags by calling the addTag() and removeTag() functions.

$('#tags').addTag('foo');
$('#tags').removeTag('bar');

If additional functionality is required when a tag is added or removed, you may
specify callback functions via the onAddTag and onRemoveTag parameters.  Both 
functions should accept a single tag as the parameter.

If you do not want to provide a way to add tags, or you would prefer to provide 
an alternate interface for adding tags to the box, you may pass an false into 
the optional 'interactive' parameter. The tags will still be rendered as per 
usual, and the addTag and removeTag functions will operate as expected.   

If you want a function to be called every time a tag is updated/deleted, set it
as the 'onChange' option.

By default, if the cursor is immediately after a tag, hitting backspace will 
delete that tag. If you want to override this, set the 'removeWithBackspace' 
option to false.

Options

$(selector).tagsInput({
   'autocomplete_url': url_to_autocomplete_api,
   'autocomplete': { option: value, option: value},
   'height':'100px',
   'width':'300px',
   'interactive':true,
   'defaultText':'add a tag',
   'onAddTag':callback_function,
   'onRemoveTag':callback_function,
   'onChange' : callback_function,
   'removeWithBackspace' : true,
   'minChars' : 0,
   'maxChars' : 0 //if not provided there is no limit,
   'placeholderColor' : '#666666'
});

jquery-tags-input's People

Contributors

erlend avatar jaylevitt avatar marioestrada avatar maxooo avatar melkorm avatar punytan avatar sebm avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.