Coder Social home page Coder Social logo

rivman / jquery-selectunique Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sshaw/jquery-selectunique

0.0 0.0 0.0 200 KB

Given a group of select fields with the same options, SelectUnique will remove an option from the other select fields when it's selected, and put it back when it's changed.

Home Page: http://sshaw.github.com/jquery-selectunique

JavaScript 100.00%

jquery-selectunique's Introduction

jQuery SelectUnique Plugin

Given a group of select fields with the same options, SelectUnique will remove an option from the other select fields when it's selected, and put it back when it's changed.

Demo

Usage

<script type="text/javascript" src="jquery-1.7.0.min.js"></script>
<script type="text/javascript" src="jquery.selectunique.js"></script>

$(selector).selectunique();

SelectUnique requires jQuery 1.7.1 or later. Options without text will be ignored.

Options

ignoreOption

$(selector).selectunique({ 
    ignoreOption: function(option) { return option.val() == 'ignore_me_buddy' } 
});

Instruct the plugin to not manage the given option. The option argument passed to the function is a jQuery object.

Methods

refresh

$(selector).selectunique('refresh');

Refresh the state of the select fields given by selector. This is useful of you're adding and/or removing select fields via JavaScript.

remaining

var opts = $(selector).selectunique('remaining');
$.each(opts, function() { 
	console.log('text: ' + this.text + ' value: ' + this.value);
});

An array of remaing options. I.e., options still available for selecting. Returns an empty array if no options are available. Each element is an HTMLOptionElement.

selected

var opts = $(selector).selectunique('selected');
$.each(opts, function() { 
	console.log('text: ' + this.text + ' value: ' + this.value);
});

An array of options that have been selected. Returns an empty array if no options have been selected. Each element is an HTMLOptionElement. While these nodes are currently selected, their selected property is false.

jquery-selectunique's People

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.