Giter Site home page Giter Site logo

select2_simple_form's Introduction

Select2SimpleForm

Select2SimpleForm is a custom input for SimpleForm which wraps and simplifies the Select2 functionality, without messing around with JS stuff.

Installation

Assuming you are using SimpleForm and a working Select2 plugin (a fast way of doing so is installing and configuring a Rails Select2 plugin, like this one). After having done this, then:

Add this to your Gemfile:

gem 'select2_simple_form'

And this into your app/assets/javascripts/application.js (making sure that the following line have to be placed after Select2 JS):

//= require select2_simple_form

And you're done my dear friend!

Usage

All you're gonna do is to use SimpleForm inputs as: :select2.

with collections

Render a Select2 simple collection (selecting a single item):

<%= f.input :countries, as: :select2, collection: Country.all %>

Render a Select2 multiple collection (selecting several items):

<%= f.input :countries, as: :select2, collection: Country.all, multiple: true %>

with ajax

Render a Select2 performing an AJAX request that finds and shows the data (selecting a single item).

<%= f.input :countries, as: :select2, ajax: 'http://route/to/get/data/for/input' %>

Render a Select2 performing an AJAX request that finds and shows the data (selecting several items).

<%= f.input :countries, as: :select2, ajax: 'http://route/to/get/data/for/input', multiple: true %>

select2_simple_form's People

Contributors

ncuesta avatar lndl avatar

Watchers

David 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.