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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 974f0b2b1af47e2135b32cc4b65e4450253be748
4
- data.tar.gz: faa108096bf05febac12c2671382a9e1db83a4ab
3
+ metadata.gz: 1aecf25283064724093b0b3a715f6cee403898c3
4
+ data.tar.gz: 0a473b40b4c3c6e40ed692bacf9251e055e7fc64
5
5
  SHA512:
6
- metadata.gz: d973cfca2a2ef7750b1c1328a0a69a6db79e09fb16b9e33ae5ea89d75376629804f169ce1fbc0960b6e38100338e4fb2179124dd0da821005276905a44772418
7
- data.tar.gz: 661061edefdd15024b2399f44c524d124fde47314d5c21e05c120cae9cdf5bc62ebeacc7b1f5d33fef64512b1a1552f56663b2784c1514d9b0a132a3e3b93c0f
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 **rails-jquery-tokeninput** you just have to add data-attribute to your text input:
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
@@ -1,7 +1,7 @@
1
1
  module Rails
2
2
  module Jquery
3
3
  module Tokeninput
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
7
7
  end
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.1.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-25 00:00:00.000000000 Z
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