GithubHelp home page GithubHelp logo

thebox193 / jquery.otherdropdown Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 3.0 292 KB

A dropdown select box where choosing 'other' prompts the user for an alternate response.

HTML 76.27% JavaScript 23.73%
jquery jquery-plugin select form forms form-controls form-input form-element dropdown

jquery.otherdropdown's Introduction

jquery.otherdropdown

A dropdown select box where choosing 'other' prompts the user for an alternate response.

alt tag

Install

NPM

  • Follow the instructions to install Node which gives you npm.
  • Switch to project folder and run yarn add jquery.otherdropdown or npm install jquery.otherdropdown --save
  • Include jquery.otherdropdown.js after jQuery is loaded in your document.

Bower

  • Follow the instructions to install Bower.
  • Switch to project folder and run bower install jquery.otherdropdown --save
  • Include jquery.otherdropdown.js after jQuery is loaded in your document.

Add to project

  • import 'jquery.otherdropdown'; or
  • <script type="text/javascript" src="./path/to/jquery.otherdropdown.min.js"></script> after the jQuery script tag

Usage

  • Bind jquery.otherdropdown to an html select, optionally pass an options object
  • $('select').otherdropdown()
  • $('.mySelect').otherdropdown({placeholder:'Type your answer'})

Options

You can pass in options to otherdropdown as an object.

  • {value: 'more'} - Optional, Value you wish to trigger the text input. default = 'other'
  • {classes: 'noborder greybg'} - Optional, clases that the text input should have. default = null
  • {placeholder: 'Type your answer'} - Optional, placeholder text on text input. default = name

Future

  • Add Callbacks hooks
  • Add tests

Support on Beerpay

Hey there! Help support me with a couple of ๐Ÿป!

Beerpay Beerpay

jquery.otherdropdown's People

Contributors

lekiy avatar thebox193 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jquery.otherdropdown's Issues

Selecting 'other' option a second time after entering no text doesn't bring up the input a second time.

This is a limitation of browser event firing. Because the input value didn't change, no change event is fired. Aka selecting 'other' then selecting 'other' again won't fire a change event. Since there appears to be no event there is no clear way to listen to this sort of behavior without having to write a workaround.

Stackoverflow has talked about this and it's workaround.

For now there is no plan to add any sort of workaround unless there is a moderate demand for it.

HTML Escaping input text

There is a bug when a user types a string with characters like " and possibly others. The input value typed doesn't get selected or doesn't display correctly. It is possible there is a XXS vulnerability since we are trusting text input values currently as well.

Check for duplicates.

Should a user type the same text twice, or type something that already is an option, it ought to be selected instead of creating a new/duplicate entry.

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.