GithubHelp home page GithubHelp logo

arendjr / selectivity Goto Github PK

View Code? Open in Web Editor NEW
1.1K 36.0 110.0 6.55 MB

Modular and light-weight selection library

Home Page: https://arendjr.github.io/selectivity/

License: MIT License

JavaScript 97.25% CSS 2.51% Shell 0.24%
javascript react jquery-plugin select component ui form

selectivity's Introduction

Selectivity.js

Modular and light-weight selection library.

Deprecation notice: At Speakap, we are migrating to a more responsive component library. As such, we will be migrating away from Selectivity, and we will no longer be maintaining this library. If you are interested in taking over ownership, please file an issue. Thanks for all the support!

Setup

Dependencies

Selectivity doesn't require any external libraries to be loaded on your page, but it does have some optional dependencies:

  • There's a React build that provides the official Selectivity React API. If you wish to use this, React should be loaded on your page.
  • There's a jQuery build that provides the official Selectivity jQuery API. If you wish to use this, either jQuery or Zepto.js should be loaded on your page.
  • The default templates assume that you have included FontAwesome in your page to display the icons. If you do not want this, please specify custom templates.

Manual

Warning: Do you use Browserify or Webpack? Please use Yarn or NPM as described below.

Download and unpack the latest release from the project website: https://arendjr.github.io/selectivity/

Copy the JavaScript and CSS file for your desired build from the archive into your project. See the following table to see which files you need:

Build JavaScript file CSS file
jQuery (development) selectivity-jquery.js selectivity-jquery.css
jQuery (production) selectivity-jquery.min.js selectivity-jquery.min.css
React (development) selectivity-react.js selectivity-react.css
React (production) selectivity-react.min.js selectivity-react.min.css
VanillaJS (development) selectivity.js selectivity.css
VanillaJS (production) selectivity.min.js selectivity.min.css

Reference the files from your HTML page like this:

<head>
    <!-- ... -->
    <link href="font-awesome.css" rel="stylesheet" />
    <link href="selectivity.css" rel="stylesheet" />
    <!-- ... -->
    <script src="jquery-or-react-or-zepto.js"></script>
    <script src="selectivity.js"></script>
    <!-- ... -->
</head>

Note the first line includes FontAwesome which is required for the default icons. This line is optional if you use custom templates.

The second line should reference the CSS file from the bundle you chose to use.

The third line should reference jQuery, React or Zepto.js as appropriate. This line is optional if you use the VanillaJS bundle. Note: If you want to use the React templates plugin, don't forget to also include react-dom.js.

Finally, the last line should reference the JavaScript file from the bundle you chose to use.

You are now ready to start using Selectivity as described on the Selectivity homepage: https://arendjr.github.io/selectivity/

Using Yarn or NPM

Use one of the following commands, depending on whether you have Yarn or NPM installed:

$ yarn add selectivity

$ npm install --save selectivity

Note you will need to include the CSS yourself. You can find it in node_modules/selectivity/selectivity.css.

Which module do I require?

You can require() Selectivity as follows:

const Selectivity = require("selectivity");

But, this will only expose the main Selectivity object and will load none of the plugins, nor enable any of the specialized APIs. You could say what you're getting is the core of the VanillaJS API.

If however, you just want to use the jQuery API with all the relevant plugins loaded, you can do this:

require("selectivity/jquery");

After this you can call the jQuery API as you would expect:

$("...").selectivity(/*...*/);

Similarly, if you want to use the React API with all its relevant plugins, you can do this:

const Selectivity = require("selectivity/react");

The Selectivity object you receive is the same one as if you'd required 'selectivity', but you get the React Component class as Selectivity.React so you can use it as follows:

<Selectivity.React {...props} />

Finally, if you're an expert (*) you can choose to use the VanillaJS API and enable just the plugins you want one by one. For example:

const Selectivity = require("selectivity");
require("selectivity/dropdown");
require("selectivity/inputs/single");
require("selectivity/plugins/ajax");
require("selectivity/plugins/async");
require("selectivity/plugins/submenu");

const singleInput = new Selectivity.Inputs.Single({
    element: document.querySelector("...")
    /* ... */
});

All the modules listed in the table below under Creating custom builds can be required this way.

*) Using the VanillaJS API isn't really that hard, but all the examples and documentation assume you're using either the React or the jQuery API, so be prepared that you'll have to figure out a bit more on your own.

Customization

Once installed, you may want to customize Selectivity. For example, by specifying custom templates or localized strings. While creating a custom build is always an option (see details below), easier options exist.

To do any basic customization, you'll need a reference to the Selectivity object. If you have installed through Yarn/NPM, you can get this object through const Selectivity = require("selectivity");. If you're using a jQuery build, the object is exposed as $.Selectivity. For non-jQuery builds that you included as a script, the object is exposed as global variable.

Example: Customizing localization in a jQuery build

$.Selectivity.Locale.noResultsForTerm = term => `No results were found for <b>${escape(term)}</b>`;

See locale.js for an overview of all localizable messages.

Example: Specifying a custom template when installed through NPM

const Selectivity = require("selectivity");
Selectivity.Templates.loading = () =>
    '<div class="selectivity-loading"><div class="my-spinner"></div></div>';

See templates.js for an overview of all templates that can be customized.

API

For usage instructions, please see the Selectivity homepage: https://arendjr.github.io/selectivity/

Browser Support

  • Chrome
  • Firefox
  • Internet Explorer 10+
  • Safari 6+

Note that while Internet Explorer versions older than 10 are not supported, you might be able to get them to work, possibly with the use of some polyfills. Reports of success or patches to create a "legacy" build would be welcomed.

Build System

Selectivity is built modularly and uses Yarn and Gulp as a build system to build its distributable files. Make sure you have the yarn command globally available. Then, inside the project directory, run:

$ yarn

Now you can generate new distributable files from the sources, using:

$ yarn build

Creating custom builds

If you want to create your own Selectivity library that contains just the modules you need, you can use the following command:

$ yarn gulp [--api=<react-or-jquery>] --modules=<comma-separated-module-list>

The following modules are available:

Module Description
inputs/email Implements the 'Email' input type. This is a special case of the 'Multiple' input type with no dropdown and a specialized tokenizer for recognizing email addresses (including pasted content from address books).
inputs/multiple Implements the 'Multiple' input type. If you only want to use Selectivity with single values, you can leave this out.
inputs/single Implements the 'Single' input type. If you only want to use Selectivity with multiple values, you can leave this out.
plugins/ajax Convenience module for performing AJAX requests. Needed if you want to use any ajax options. If you use this module, you should also include the 'async' module to correctly handle out-of-order replies. This module relies on the presence of the [fetch()](https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch) method which is only available in modern browsers, so you should either provide a polyfill if you want to support older browsers, or -- if you're creating a jQuery build -- you can use the 'jquery/ajax' module to provide a fallback that uses $.ajax() instead.
plugins/async Blocks the query function from calling its callback functions if another query has been issued since. This prevents out-of-order replies from remote sources to display incorrect results. This module is only needed if you use the query function and call its callbacks asynchronously.
plugins/diacritics Diacritics support. This will make sure that "Łódź" will match when the user searches for "Lodz", for example. However, if you always query a server when searching for results, you may want to solve matching of diacritics server-side, in which case this module can be omitted.
plugins/keyboard Provides keyboard support for navigating through the dropdown. If you don't use a dropdown, or are only targeting mobile, you may want to leave this module out.
plugins/submenu Extends the default dropdown so that multiple levels of submenus can be created.
plugins/tokenizer Default tokenizer implementation. This module adds support for the tokenSeparators option which is used by the default tokenizer. Support for tokenizers themselves is already included in the "multiple" module, so you can omit this module if you don't want to use any tokenizers or want to specify your own tokenizer.
plugins/jquery/ajax Provides a fallback to use $.ajax() instead of the fetch() method for performing AJAX requests. (Requires jQuery 3.0 or higher)
plugins/jquery/traditional This module allows you to convert an HTML5 <select> form element into a Selectivity instance. The items will be initialized from the <option> and <optgroup> elements. (jQuery only)
plugins/react/templates Adds support for React (JSX) templates. Requires react-dom to be available.
dropdown Module that implements the dropdown. You will most likely want to include this, unless you only want to use Selectivity without any dropdown or you provide a completely custom implementation instead.
locale Localizable content pulled in by the default templates. You may or may not decide to use these with your own templates. Also used for localizable messages by the ajax module.
templates Default templates to use with Selectivity. If you provide your own templates, you may want to skip this.

Note that the build system automatically resolves dependencies between modules. So for example, if you specify you want the submenu plugin, the dropdown module will be automatically included.

Example:

$ yarn gulp --api=react --modules=inputs/multiple,dropdown

This will create a custom build that uses the React API and which has support for selecting multiple values with a dropdown. The build will be saved in build/selectivity-custom.js. There will be no plugins available, you will have to provide your own templates with their localizable content, and you cannot use this build for creating a single-select input.

To display any other options available for custom builds, run gulp usage.

Development server

While developing, you can start a development server like this:

$ yarn start [--api=<jquery-or-react>]

You can reach the development server on the URL printed on the console (typically http://localhost:3000), and you'll probably want to open one of the demos there:

Unit Tests

Unit tests are available and can be ran using the following command:

$ yarn unit-tests

If you want to run an individual test, just add --test=<test-name>. Simply provide an invalid test name to get a list of all available test names.

License

Selectivity is made available under the MIT license.

Contributing

To read more about guidelines for submitting pull requests, please read the Contributing document.

selectivity's People

Contributors

ahamid avatar andrii-maglovanyi avatar arendjr avatar darekzak avatar dmarchuk avatar dr-itz avatar gfellerph avatar glafarge avatar greenkeeper[bot] avatar greenkeeperio-bot avatar leodt avatar msx2 avatar r4z3c avatar watsab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

selectivity's Issues

Compare values from 2 selects

Hello.. I love your pplugin and I want suggest one thing.

I dev one project, and I need compare 2 select, this is like for example, from - to, From London, in "TO" select, I need locked that option, I cant go from London to London :P

It's my suggestion, I think is not possible yet.

Preset of ajax result

Hi, I tried your library but i have a little problem : how may I preset a data in my ajax data list, only with the Id ? I've read in the documentation that we have to put the 'initSelection' method but if it's the solution, i don't understant how...

Thank you for your help

iOS 8.3 issues

  1. On choice cursor placed to second position, like B|arcelona
  2. Scrolling is jerky and slow, may be defining: -webkit-overflow-scrolling: touch; will fix it.
  3. Clear icon is too small for normal usage on touch devices (the same for dropdown icon). Probably this can be be fixed in CSS, so not a real issue.

Another way to implement multiple selection

Hi,
I don't like Select2. Just like you - I began to write my own implementation of <select> replacement script. I gave up because I felt like I'm starting to getting lost with it - I've never had written proper JS library - so my script currently likes to position dropdown wrong (should be easy to fix) and has no support for <optgroup> (harder to fix). I've tried many such scripts, but none of them managed to get one thing "right" for me - the multiple selections. Look what I've done:
https://www.dropbox.com/s/o2eqyf9no7kiy4m/2015-08-04_09-19-17.mp4?dl=0 (175KB, no worries about big DL)

I'd like to request something like that.
I select one element - it looks just like a single dropdown. I select two or more (I can just click-click-click and dropdown stays open) - it just shows "Multiple selection [count]". My script had (AFAIR I removed it for some reason) also an option to show selected items separated by comma. It's not a big deal to change this anyway and I'll be happy with any of this.

Do you think you'll be able to implement such thing? What do you think about this idea?

Oh, and if you for some reason want to see my library I can publish it. I was planning to do this when I think I'm happy with the results, but currently I am not.

Serious bug with keyboard navigation within dropdown

There is a serious usability issue with keyboard navigation of the dropdown contents.

For example, let's look at the very first example (Select a single city).

  1. I focus on the element and begin pressing the down arrow. When getting to the last item visible and pressing the down arrow once more the whole page shifts so the bottom of the dropdown is at the bottom of the browser viewport.
  2. Now I start pressing the up arrow and move up to the first visible item in the dropdown. Pressing the up arrow once more results in the page shifting so the top of the dropdown is at the very top of the browser viewport.
  3. Now here is where it gets REALLY messed up. If the mouse position happens to be over the dropdown area, then whenever the keyboard navigation in the dropdown moves past the first or last visible item in the dropdown not only will the above two issues occur but the item under the mouse cursor gets selected which can result in a loop making it extremely hard to actually move up or down the list of items.

Issues 1 and 2 happen in Chrome, Firefox, and IE10. Issue 3 happens in Chrome and Firefox, but interestingly enough doesn't seem to happen in IE10.

It's hard to explain in writing. The best thing is just to test out the keyboard navigation on the example page.

Traditional module don't wok

Hi!
I have multiselect element on my html page and I want to use Selectivity to decorate this select, but this not work.

    <select multiple id="test">
        <option selected value="1">Volvo</option>
        <option value="2">Saab</option>
        <option value="3">Opel</option>
        <option value="4">Audi</option>
    </select>
$('#test').selectivity({placeholder: 'Type to search'});

When I click on selectivity input, dropdown show Loading... , in javascript console I get error TypeError: this.$searchInput is null selectivity-full.js:3358:12

Please, help.
Thanks.

Ajax submenu

Hi Guys!
You create cool selectivity!
Can you help me to generate selectivity with submenu via ajax?

SingleSelectivity new Item

How can I enable creating new Item, like the email/multiple, but single, and with dropdown select?
( if category not found in the list, enter name of new category... )
use the query somehow?

Unable to Select Matched Results with Mouse

Hi I am unable to select the matched results with a mouse. I can hit the "down" key on the keyboard to highlight a result and hit the "enter" to select a result. But I cant hover over a result and click with mouse to select it:

var self = this;
var staticdata = [{ id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];
    self._selectivity = self.$().selectivity({
        items: staticdata,
        placeholder: 'No city selected',
        multiple: true
});

Error when using submenu with "showSearchInput": true and "multiple": true

The following error occurs when using submenu with "showSearchInput": true and "multiple": true :

Uncaught TypeError: Cannot read property 'before' of null in selectivity-full.js:3611

with selectivity-full.js:3611 being the this.$searchInput.before from _renderSelectedItem

Basic example :

  $('#example-1').selectivity(
  {
    "items": [
    {
      "id": 1,
      "text": "one",
      "submenu":
      {
        "items": [
        {
          "id": 1,
          "text": "subOne"
        },
        {
          "id": 2,
          "text": "subTwo"
        }],
        "showSearchInput": true
      }
    }],
    "placeholder": 'No filter selected',
    "multiple": true
  });

A basic example reproducing the error is available here : https://jsfiddle.net/XavM75/fwnjx1b9/3/

User avatar image for a userlist selector

With Select2 I am able to build a userlist selector which shows a username next to a thumbnail avatar image. Once a user is selected, it also shows the image and name.

Is this possible using the templates in this library> I didn't see any images in the demos so I am assuming it might not be?

BTW great library!

jquery 'too much recursion' error when showSearchInputInDropdown is false

I have the following piece of code:

function set_subtipo_espectaculo_selectivity() {
    $('#subtipo').selectivity({
        allowClear: false,
        placeholder: 'Seleccione un subtipo de espectáculo',
        showSearchInputInDropdown: false
    });

Which produces this error:

too much recursion
/script/jquery.min.js
Line 4614

But if I comment showSearchInputInDropdown it works perfectly. Now, the code with or without the error does its job, but I find it odd to produce such error.

How to obtain selected data?

I have a select tag named "element". I use select3 like this:
$('#element').select3({multiple:true}).

It works fine, but when I select items I want the data accessible in code. When I use this
$('#element').select3('data')
as the API indicates, I get this error:

Cannot call method on element without Select3 instance

Can you tell me what I'm doing wrong?

Example for own inputType

Hi,

great library :) I have some troubles with own inputType. I dont know how to start.
Can you please post an example for own customType?

I need some like email, but for any text und in combination with select-items. If the input text is not in the list, then make a token (not multiple).

many thanks :)

PS: Sorry for my bad english

Module problems

Hello dear friends,
I have trouble problem,

http://i.imgur.com/1EzV9EF.png

Details:

It is inside a Bootstrap modal. I have tried your z-index fix.
When I click the list, it closes.
I cannot scroll.
I can search.
The blue active class is not applied to items I hover over. They stay at the top item.

This is my code.

select id="dropdown-devices" name="devices"
{{ for loop for options }}
/select

Without brackets around select element.

var dDev = $("#dropdown-devices").selectivity();

What am I doing wrong?

Thank you for your time.

Item partially out of view when scrolling list with keyboard

I'm thrilled that you fixed the #41 issue!

However I noticed a relatively minor issue when scrolling down through the list with the keyboard where the item at the bottom of the list is halfway out of view. This is probably a very easy fix but I'm not sure where to look. Screenshot attached.
selectivity_keyboard_nav1

Maybe pick another name?

This looks like a really great project, kudos.

I couldn't help but wince at the name. Unless you have an agreement with the people behind select2, I think you should consider picking a different name.

From the standard naming patterns (Windows 7 < Windows 8 < Windows 9), the name could be interpreted as this being a newer, better version of select2, rather than a different project.

Additionally, the current stable version of select2 is 3.x. So there's also a lot of potential for confusion between select2 3.x and select3 1.x. And this will just get worse over time.

So from my perspective (which could, of course, be completely mistaken), I think the classy thing to do was to change the name.

Error in Website documentation

On your website https://arendjr.github.io/selectivity/ you mention the event for when the dialogue is closed is: selectivity-closed

but it is selectivity-close

Compliance with standard web form elements

Currently when you define a selectivity input out of standard HTML's:

  • select, this element gets replaced completely with selectivity input
  • input, the logic works, but everything is appended into the input tag, creating something like <input>...</input>

What about support for standard web forms? If I try to turn select into selectivity input, it will end up with removing the select field completely from the form. That shouldn't be the case.

The similar situation is multiple: true defined on the input. The logic seems to operate, but nothing happens, and field is removed from the form as well.

Select2 has this not-really-so-great approach of hiding those standard elements and injecting/updating values within once selection is made, but that's actually pretty awesome as it allows users to prettify the select boxes and not modify anything else about the code for it to work as it should (and did).

Allow `ajax` based options load in `select` elements.

Whenever we use select element selectivity uses its option to create items array. But we need to be able to override this behavior so we ourselves can define whether to load item dynamically in that situation or not. Currently we need to either use text input or some other div or span element. But In the end most suitable option will be to be able to use select element with ajax based options loading.

Displaying long labels in multiple select

If multi-select item is too long in name, you can't remove it by clicking on x icon. Here's the effect of this:

screen shot 2015-04-17 at 14 37 53

@arendjr What do you think of moving the x icon to the left, just like in select2? This is the quickest and easiest fix I can think of. Otherwise we'd need to consider trimming the label in JS/rebuilding component introducing yet another div/span inside.

Allow z-index to be customizable

I'm currently using selectivity in a project, and it sits next to another widget that also allows a popup. However the z-index : 9999 on the selectivity <div> causes the selectivity widget to appear over the other popup.

It would be helpful to provide an option to allow us to modify how it displays to fix these kinds of conflicts.

Something like this maybe:

$('#tag-id').selectivity({
    items: [ {id:0, text:'no items loaded' }],
    multiple: true,
    placeholder:label,
    foregroundZIndex:999
});

Trailing commas

There seem to be trailing commas in some modules (I found 3 while compiling my custom version of selectivity). I will create a pull request which removes the trailing commas I found. The google closure compiler http://closure-compiler.appspot.com/home reported these errors while trying to minify the custom script.

Keyboard accessibility

Hello,

would by nice to have better keyboard accessibility. For example when you pick option in dropdown (click or enter), select lose focus, so you cannot opened it again with enter.

Select with submenu is not accessible at all with keyboard.

Otherwise nice modularised design.

way to distinct between closed, hover and open state

It would be nice to have some way to change styling depending on what state the dropdown is in.

This would mean that we would need to add class to the selectivity-*-select when desired state is activated.

onHover: class="hover"
whenOpen: class="open"

Positioning of Dropdown inside relative element

When selectivity element is inside of a position:relative element the opening of dropdown looks like a bug, `cos dropdown get its offset relatively to browser window (?) but not for the selectivity element, so the only way to fix it now is to set manually top and right css properties

It would be great to see an option to set dropdown relatively to input, not browser window.

Input search vs backspace

If you filter the list using Selectivity.js search module, you might end up with something like that:

screen shot 2015-04-17 at 15 35 42

I typed b in search field, and then removed it with backspace. To refresh the list one must either type something else or press function key other than backspace.

I didn't observe the issue using delete - well, at least using OSX's fn+backspace.

returning data

If I just want to query the DB based off the search term entered, what do I need to return? I am getting an offset and map error when I just return an object. I can not find an example of simple data return.

Native change event with showSearchInDropdown: false

Hi! First, let me say I'm really appreciating selectivity. I struggled with twitter's Typeahead for far too long before abandoning it in favour of Selectivity.

I do like Typeahead's interaction better where the user's typed text appears in an input field instead of in the drop-down menu. Much like your multiple select example. Here's the Typeahead example. I'm trying to more-or-less reproduce it with Selectivity using the showSearchInputInDropdown option.

image

So, two things:
First, an example using showSearchInputInDropdown: false but with an input field showing would be helpful.
Second, I note an inconsistency in how change events are handled. In the following, when showSearchInputInDropdown is true, Abc<return> (ie: type a non-existant entry) and Ams<tab> (tab to select a chose entry) don't fire any events. If showSearchInputInDropdown is false, both fire the native change event (Selectivity's additional fields aren't added).

What I'd hope for is that both Abc<return> and Ams<tab> would fire a change event where the event has been augmented with Selectivity's fields.

<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link href="css/selectivity-full.css" rel="stylesheet">

    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/selectivity-full.js"></script>
</head>
<body>

<h1>Selectivity Testing</h1>

<div id="search"></div>

<script type="text/javascript">
$('#search').selectivity({
    showSearchInputInDropdown: false,
    items: ['Abu Dhabi', 'Abuja', 'Accra', 'Adamstown', 'Addis Ababa', 'Algiers', 'Alofi', 
        'Amman', 'Amsterdam', 'Ankara', 'Antananarivo', 'Apia']
    }).on('change', function(ev){
        console.log("change event:  added="+ev.added+" removed="+ev.removed+" value="+ev.value);
    }).on('selectivity-selecting', function(ev){
        console.log("selectivity-selecting event:  id="+ev.id+" item="+ev.item);
    }).on('selectivity-selected', function(ev){
        console.log("selectivity-selected event:  id="+ev.id+" item="+ev.item);
     });
</script>

</body>
</html>

Thanks again for the great job so far!

Highlighting of matched text

I've search through the docs and issues and don't see any mention of being able to highlight matched text in the results list. Am I missing something?

The best option in my opinion would be to wrap matching text with a span element that could be styled in the CSS file.

Dropdown positioning in relative container

After the recent changes there's an issue with positioning the dropdown inside relative container, e.g. add the following to one of the <p>aragraphs on demo pages that contain selectivity inputs:

width: 50%;
margin: 0 auto;
position: relative;

This will result in:
screen shot 2015-04-07 at 22 20 55

I wanted to update gh-pages branch to consist the newest build, and saw it happen there.

By the way, @arendjr, is there any way to contact you directly? I tried Twitter, but figured you don't use it on a daily basis :)

Search input is missing the type=text attribute

Selectivity renders the search input as:

<input class="selectivity-search-input">

This is valid HTML because it will default to text, however some selectors won't find this input with 'input[type=text]--including jQuery. Better to be explicit.

Great select control; thank you so much!

API Methods throws error

On API example page
$('#example-1').selectivity('remove') throws an error Unknown method: remove
as well as some other methods

"triggerChange: false" ignored when calling value API

I'm calling the API like this:

$(el).selectivity('value', value, {triggerChange:false})

But the change event is still triggered anyway. In a debugger I can see that in the value method options argument is undefined so it looks like the object with options gets lost somewhere on the way.

selectivity-multiple - Enter - preventDefault

The multiple select while inside a form - Enter Key submits. I've fixed it this way:

_keyHeld: function(event) {

        this._originalValue = this.$searchInput.val();

        if (event.keyCode === KEY_ENTER && !event.ctrlKey) {

            // console.log( this.dropdown );
            event.preventDefault();
        }

    }

Dropdown positioning

As discussed in #24, the idea would be to use position: relative container, and append dropdown to this container, not to body. Thus, dropdown would have the following styling:

  • top: $actual-input-height for bottom-oriented dropdown
  • bottom: $actual-input-height for top-oriented dropdown

Also, there's an issue with detecting the orientation for the multiple select dropdown. If dropdown list does not fit the viewport height, no matter how much space it has at the top, it will open as top-oriented.

screen shot 2015-04-17 at 15 32 38

I believe it should open as the bottom-oriented :)

The same situation makes single select dropdown also display in wrong place. It does open as bottom-oriented, but not attached to its trigger (.selectivity-input) - this will be fixed automatically while using top/bottom approach.

Load items dynamically from custom source

I think it would be very useful to provide an interface similar like ajax but user can decide what's the source of the data.

Option something like this:

items: function (term, offset, callback) {
  MyModel.getItems({
   term: term
  }, function (err, results) {
   // transform results
   callback(err, results);
  });
}

Item Removed Event

I think having event for just item removing can be good.

this.$el.trigger('selectivity-removed', {});

It will help user not to implement change event and listen every changes

Method to clear

Right now this works:

this.$ele.select3('data', null);

Maybe we should do a proper .clear() or document the one above?

Cheers

Dropdown position

Hey!
How I can do that my dropdown, when I open him, was always be under select menu instead of calculated position.

Method to 'disable' and 'enable' selection.

I need to disable/enable selection based on a second combo-box So currently i need methods to disable and enable selectivity so that user interaction with can be controlled.
Currently to achieve this i am doing this: If i need to disable selection then just destroy it. And if i need to enable it again then just apply selectivity again. I don't think this is a very good workaround. Most of other plugin also provide support for disabling user selection at runtime.

P.S: i know there's an option for declaring selectivity as readonly but i need to be able to change it at runtime through API call.

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.