rails-jquery-tokeninput 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/assets/javascripts/rails-jquery-tokeninput.js +15 -0
- data/lib/rails/jquery/tokeninput/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aecf25283064724093b0b3a715f6cee403898c3
|
4
|
+
data.tar.gz: 0a473b40b4c3c6e40ed692bacf9251e055e7fc64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16ebc5c2004ceb043277bac51dd66decb12c87b45da3ef60ce849876392bb3bb0aa794919dee24764de1d99c14f454697b6317db7e87c8b63b39f12e7034b550
|
7
|
+
data.tar.gz: 8b9da0d1b60208136af18181379e7aebd8250210e9499cc48b1e970e3aa6ebc6e6cda715f0848976910d0c063f3a86b1c746f2614f89f1a8eb8e871e53746fcb
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ Add the stylesheets you want to use in your application.css:
|
|
30
30
|
|
31
31
|
## Usage
|
32
32
|
|
33
|
-
To start using
|
33
|
+
To start using gem you just have to add data-attribute to your text input:
|
34
34
|
|
35
35
|
```ruby
|
36
36
|
names = [{ id: 1, name: 'John' }, { id: 2, name: 'Mike' }]
|
@@ -49,6 +49,8 @@ f.input :countries, as: :string, input_html: {
|
|
49
49
|
}
|
50
50
|
```
|
51
51
|
|
52
|
+
It will automatically pass input values to your controller like an array.
|
53
|
+
|
52
54
|
## Contributing
|
53
55
|
|
54
56
|
1. Fork it
|
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
$(function() {
|
4
4
|
$.each($('input[data-tokeninput]'), function(index, input) {
|
5
|
+
var inputName = $(input).attr('name')
|
6
|
+
$(input).attr('name', '');
|
7
|
+
|
8
|
+
$(input).data('tokeninput').options.onAdd = function(item) {
|
9
|
+
var inputItemName = inputName + '[]';
|
10
|
+
var inputItemValue = item[$(input).data('tokeninput').options.tokenValue || 'id'];
|
11
|
+
|
12
|
+
$('<input name="' + inputItemName + '" type="text" style="display: none;" value="' + inputItemValue + '">').insertAfter(input);
|
13
|
+
};
|
14
|
+
|
15
|
+
$(input).data('tokeninput').options.onDelete = function(item) {
|
16
|
+
var inputItemValue = item[$(input).data('tokeninput').options.tokenValue || 'id'];
|
17
|
+
$('input[value="' + inputItemValue + '"]').remove();
|
18
|
+
};
|
19
|
+
|
5
20
|
$(input).tokenInput(
|
6
21
|
$(input).data('tokeninput').collection,
|
7
22
|
$(input).data('tokeninput').options
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-jquery-tokeninput
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeny Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: rails-jquery-tokeninput project integrates Tokeninput jQuery plugin which
|
14
14
|
allows your users to select multiple items from a predefined list, using autocompletion
|