Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonytonyjan/select2_helper
https://github.com/tonytonyjan/select2_helper
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/tonytonyjan/select2_helper
- Owner: tonytonyjan
- License: mit
- Created: 2014-05-27T18:51:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-04T09:48:27.000Z (almost 9 years ago)
- Last Synced: 2024-04-09T21:30:15.569Z (9 months ago)
- Language: Ruby
- Size: 42 KB
- Stars: 0
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
Install
=======`Gemfile`
```ruby
gem 'select2_helper', github: 'tonytonyjan/select2_helper'
````application.js`
```coffee
//= require select2
//= require select2_helper
```Usage
=======Let project has many tasks.
`project.rb`
------------```ruby
class Project < ActiveRecord::Base
include Select2Concern
select2_white_list :name
has_many :tasks
end```
`task.rb`
---------```ruby
class Task < ActiveRecord::Base
include Select2Concern
select2_white_list :status
belongs_to :project
end
```Single Select
-------------```erb
<%=
text_field_tag :single_demo, nil,
class: 'select2-single',
data: {
model: :Project,
column: :name
}
%>
```Multiple Select
---------------```erb
<%=
text_field_tag :multiple_demo, nil,
class: 'select2-multiple',
data: {
model: :Project,
column: :name
}
%>
```Nested Select
-------------```erb
<%=
text_field_tag :level_1, nil,
class: 'select2-single',
data: {
model: :Project,
column: :name,
child_field: '#level_2'
}
%><%=
text_field_tag :level_2, nil,
data: {
model: :Task,
column: :status,
foreign_key: :project_id
}
%>
```Simple Form Compatiable
=======================In `application.css`
```css
/*
= require select2_simple_form_compatible
*/
```