Socket
Book a DemoInstallSign in
Socket

auto_select2_tag

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto_select2_tag

0.2.2
bundlerRubygems
Version published
Maintainers
2
Created
Source

AutoSelect2Tag

Provide tag-helper methods for create Select2 elements by the same way as any other view elements.

Gem Version

Installation

Firstly install AutoSelect2 with dependency. Then add this line to your application's Gemfile:

gem 'auto_select2_tag'

And execute:

$ bundle

Example

You can find example project here.

Usage

Gem provide only two helper methods for initialize select2 elements:

  • select2_tag
  • select2_ajax_tag

details about realization you can find on AutoSelect2 page.

select2_tag

select2_tag(name, option_tags = nil, options = {})

Has same behavior as common select_tag. In addition you can specify :select2_options in options. This parameter allow to set select2 constructor options.

Example of usage select2_tag

= select2_tag :select2_name,
               my_options_for_select2(my_init_value),
               placeholder: 'Fill me!',
               include_blank: true,
               select2_options: {width: 'auto'}

select2_ajax_tag

select2_ajax_tag(name, select2_searcher, value = nil, options = {})

All allowed options for this helper can be found on AutoSelect2 page. look at example below; this is an easy way to understand helper parameters.

Example of usage select2_ajax_tag

If you define SearchAdapter named MySearchAdapterName, you can use the follow code:

= select2_ajax_tag :my_select2_name,
                   :my_search_adapter_name,
                   my_init_value_id,
                   placeholder: 'Fill me now!',
                   search_method: :unusual_case,
                   class: 'my-select2-input',
                   select2_options: {additional_ajax_data: {selector: '.additional-elements'}}

If you want lightweight selection over columns of ActiveRecord model:

= select2_ajax_tag :my_select2_name,
                   {class_name: :your_model_name, text_column: :name, id_column: :id},
                   my_init_value_id,
                   placeholder: 'Fill me now!'

In this case you get select2 selent with search by name column over model YourModelName.

Contributing

  • Fork it ( http://github.com/Loriowar/auto_select2_tag/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 12 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.