暫無描述

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Bootstrap Multiselect</title>
  5. <meta name="robots" content="noindex, nofollow" />
  6. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  7. <link rel="stylesheet" href="docs/css/bootstrap-3.3.2.min.css" type="text/css">
  8. <link rel="stylesheet" href="docs/css/bootstrap-example.css" type="text/css">
  9. <link rel="stylesheet" href="docs/css/prettify.css" type="text/css">
  10. <script type="text/javascript" src="docs/js/jquery-2.1.3.min.js"></script>
  11. <script type="text/javascript" src="docs/js/bootstrap-3.3.2.min.js"></script>
  12. <script type="text/javascript" src="docs/js/prettify.js"></script>
  13. <link rel="stylesheet" href="dist/css/bootstrap-multiselect.css" type="text/css">
  14. <script type="text/javascript" src="dist/js/bootstrap-multiselect.js"></script>
  15. <script type="text/javascript" src="dist/js/bootstrap-multiselect-collapsible-groups.js"></script>
  16. <script type="text/javascript">
  17. $(document).ready(function() {
  18. window.prettyPrint() && prettyPrint();
  19. });
  20. </script>
  21. </head>
  22. <body data-spy="scroll" data-target="#affix">
  23. <a href="https://github.com/davidstutz/bootstrap-multiselect"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
  24. <div class="container">
  25. <div class="row">
  26. <div class="col-md-3" id="affix">
  27. <ul class="nav nav-pills nav-stacked sidebar" data-spy="affix" style="margin-top: 40px;">
  28. <li class="active"><a href="#getting-started">Getting Started</a></li>
  29. <li><a href="#configuration-options">Configuration Options</a></li>
  30. <li><a href="#templates">Templates</a></li>
  31. <li><a href="#methods">Methods</a></li>
  32. <li><a href="#further-examples">Further Examples</a></li>
  33. <li><a href="#post">Server-Side Processing</a></li>
  34. <li><a href="#keyboard-support">Keyboard Support</a>
  35. <li><a href="#faq">Frequently Asked Questions</a></li>
  36. <li><a href="#known-issues">Known Issues</a></li>
  37. <li><a href="tests/SpecRunner.html">Tests</a></li>
  38. <li><a href="#license">License</a></li>
  39. </ul>
  40. </div>
  41. <div class="col-md-9">
  42. <div class="page-header">
  43. <h1>Bootstrap Multiselect</h1>
  44. </div>
  45. <p class="alert alert-warning">
  46. <b>Some option names may have changed during the last few commits!</b>
  47. </p>
  48. <p class="alert alert-info">
  49. <b>Please consult the <a href="#faq">FAQ</a> and the <a href="https://github.com/davidstutz/bootstrap-multiselect/issues">Issue Tracker</a> before creating a new issue.</b>
  50. </p>
  51. <p class="alert alert-info">
  52. <b>Please have a look at <a href="#how-to-contribute">How to contribute?</a> and the <a href="https://github.com/davidstutz/bootstrap-multiselect/issues">Issue Tracker</a>.</b>
  53. </p>
  54. <div class="page-header">
  55. <h2 id="getting-started">Getting Started</h2>
  56. </div>
  57. <ol>
  58. <li>
  59. <h3>Link the Required Files</h3>
  60. <p>
  61. First, the <a href="http://jquery.com/" target="_blank">jQuery</a> library needs to be included. Then <a href="http://getbootstrap.com" target="_blank">Twitter Bootstrap</a> - both the Javascript library and the CSS stylesheet - needs to be included.
  62. </p>
  63. <pre class="prettyprint linenums">
  64. &lt;!-- Include Twitter Bootstrap and jQuery: --&gt;
  65. &lt;link rel=&quot;stylesheet&quot; href=&quot;css/bootstrap.min.css&quot; type=&quot;text/css&quot;/&gt;
  66. &lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.min.js&quot;&gt;&lt;/script&gt;
  67. &lt;script type=&quot;text/javascript&quot; src=&quot;js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
  68. &lt;!-- Include the plugin's CSS and JS: --&gt;
  69. &lt;script type=&quot;text/javascript&quot; src=&quot;js/bootstrap-multiselect.js&quot;&gt;&lt;/script&gt;
  70. &lt;link rel=&quot;stylesheet&quot; href=&quot;css/bootstrap-multiselect.css&quot; type=&quot;text/css&quot;/&gt;
  71. </pre>
  72. <p>
  73. The jQuery library can also be included using a CDN, for example the <a href="https://developers.google.com/speed/libraries/devguide?hl=de&csw=1#jquery">Google CDN</a>:
  74. </p>
  75. <pre class="prettyprint linenums">
  76. &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"&gt;&lt;/script&gt;
  77. </pre>
  78. <p class="alert alert-info">
  79. Note that the plugin will work both with version 2.x of the jQuery library as well as with version 1.10.x of the jQuery library. So for using the Google CDN you may have to adjust the version.
  80. </p>
  81. </li>
  82. <li>
  83. <h3>Create a Select</h3>
  84. <p>
  85. Now simply use HTML to create your <code>select</code> input which you want to turn into a multiselect. Remember to set the <code>multiple</code> attribute as to get a real multiselect - but do not worry, the plugin can also be used as usual select without the <code>multiple</code> attribute being present.
  86. </p>
  87. <pre class="prettyprint linenums">
  88. &lt;!-- Build your select: --&gt;
  89. &lt;select id=&quot;example-getting-started&quot; multiple=&quot;multiple&quot;&gt;
  90. &lt;option value=&quot;cheese&quot;&gt;Cheese&lt;/option&gt;
  91. &lt;option value=&quot;tomatoes&quot;&gt;Tomatoes&lt;/option&gt;
  92. &lt;option value=&quot;mozarella&quot;&gt;Mozzarella&lt;/option&gt;
  93. &lt;option value=&quot;mushrooms&quot;&gt;Mushrooms&lt;/option&gt;
  94. &lt;option value=&quot;pepperoni&quot;&gt;Pepperoni&lt;/option&gt;
  95. &lt;option value=&quot;onions&quot;&gt;Onions&lt;/option&gt;
  96. &lt;/select&gt;
  97. </pre>
  98. </li>
  99. <li>
  100. <h3>Call the Plugin</h3>
  101. <p>
  102. In the end, simply call the plugin on your <code>select</code>. You may also specify further options, see the Options tab for further information.
  103. </p>
  104. <div class="example">
  105. <script type="text/javascript">
  106. $(document).ready(function() {
  107. $('#example-getting-started').multiselect();
  108. });
  109. </script>
  110. <select id="example-getting-started" multiple="multiple">
  111. <option value="cheese">Cheese</option>
  112. <option value="tomatoes">Tomatoes</option>
  113. <option value="Mozzarella">Mozzarella</option>
  114. <option value="Mushrooms">Mushrooms</option>
  115. <option value="Pepperoni">Pepperoni</option>
  116. <option value="Onions">Onions</option>
  117. </select>
  118. </div>
  119. <div class="highlight">
  120. <pre class="prettyprint linenums">
  121. &lt;!-- Initialize the plugin: --&gt;
  122. &lt;script type=&quot;text/javascript&quot;&gt;
  123. $(document).ready(function() {
  124. $(&#39;#example-getting-started&#39;).multiselect();
  125. });
  126. &lt;/script&gt;
  127. </pre>
  128. </div>
  129. </li>
  130. </ol>
  131. <div class="page-header">
  132. <h2 id="configuration-options">Configuration Options</h2>
  133. </div>
  134. <p class="alert alert-info">
  135. Use Firebug, Chrome Developer Tools to get the best out of the below examples.
  136. </p>
  137. <table class="table">
  138. <tbody>
  139. <tr>
  140. <td><code>multiple</code></td>
  141. <td>
  142. <p>
  143. <code>multiple</code> is not a real configuration option. It refers to the <code>multiple</code> attribute of the <code>select</code> the plugin is applied on. When the <code>multiple</code> attribute of the <code>select</code> is present, the plugin uses checkboxes to allow multiple selections. If it is not present, the plugin uses radio buttons to allow single selections. When using the plugin for single selections (without the <code>multiple</code> attribute present), the first option will automatically be selected if no other option is selected in advance. See <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/129">#129</a> for how to avoid this behavior.
  144. </p>
  145. <p>
  146. The following example shows the default behavior when the <code>multiple</code> attribute is omitted:
  147. </p>
  148. <div class="example">
  149. <script type="text/javascript">
  150. $(document).ready(function() {
  151. $('#example-single').multiselect();
  152. });
  153. </script>
  154. <select id="example-single">
  155. <option value="1">Option 1</option>
  156. <option value="2">Option 2</option>
  157. <option value="3">Option 3</option>
  158. <option value="4">Option 4</option>
  159. <option value="5">Option 5</option>
  160. <option value="6">Option 6</option>
  161. </select>
  162. </div>
  163. <div class="highlight">
  164. <pre class="prettyprint linenums">
  165. &lt;script type=&quot;text/javascript&quot;&gt;
  166. $('#example-single').multiselect();
  167. &lt;/script&gt;
  168. &lt;!-- Note the missing multiple attribute! --&gt;
  169. &lt;select id="example-single"&gt;
  170. &lt;option value="1"&gt;Option 1&lt;/option&gt;
  171. &lt;option value="2"&gt;Option 2&lt;/option&gt;
  172. &lt;option value="3"&gt;Option 3&lt;/option&gt;
  173. &lt;option value="4"&gt;Option 4&lt;/option&gt;
  174. &lt;option value="5"&gt;Option 5&lt;/option&gt;
  175. &lt;option value="6"&gt;Option 6&lt;/option&gt;
  176. &lt;/select&gt;
  177. </pre>
  178. </div>
  179. <p>
  180. If multiple options are selected in advance and the <code>select</code> lacks the <code>multiple</code> attribute, the last option marked as <code>selected</code> will initially be selected by the plugin.
  181. </p>
  182. <div class="example">
  183. <script type="text/javascript">
  184. $(document).ready(function() {
  185. $('#example-single-selected').multiselect();
  186. });
  187. </script>
  188. <select id="example-single-selected">
  189. <option value="1">Option 1</option>
  190. <option value="2" selected="selected">Option 2</option>
  191. <option value="3" selected="selected">Option 3</option>
  192. <option value="4">Option 4</option>
  193. <option value="5">Option 5</option>
  194. <option value="6">Option 6</option>
  195. </select>
  196. </div>
  197. <div class="highlight">
  198. <pre class="prettyprint linenums">
  199. &lt;script type=&quot;text/javascript&quot;&gt;
  200. $('#example-single-selected').multiselect();
  201. &lt;/script&gt;
  202. &lt;!-- Note the missing multiple attribute! --&gt;
  203. &lt;select id="example-single-selected"&gt;
  204. &lt;option value="1"&gt;Option 1&lt;/option&gt;
  205. &lt;option value="2" selected="selected"&gt;Option 2&lt;/option&gt;
  206. &lt;!-- Option 3 will be selected in advance ... --&gt;
  207. &lt;option value="3" selected="selected"&gt;Option 3&lt;/option&gt;
  208. &lt;option value="4"&gt;Option 4&lt;/option&gt;
  209. &lt;option value="5"&gt;Option 5&lt;/option&gt;
  210. &lt;option value="6"&gt;Option 6&lt;/option&gt;
  211. &lt;/select&gt;
  212. </pre>
  213. </div>
  214. <p>
  215. The following example shows the default behavior when the <code>multiple</code> attribute is present. Initially selected options will be adopted automatically:
  216. </p>
  217. <div class="example">
  218. <script type="text/javascript">
  219. $(document).ready(function() {
  220. $('#example-multiple-selected').multiselect();
  221. });
  222. </script>
  223. <select id="example-multiple-selected" multiple="multiple">
  224. <option value="1">Option 1</option>
  225. <option value="2" selected="selected">Option 2</option>
  226. <option value="3" selected="selected">Option 3</option>
  227. <option value="4">Option 4</option>
  228. <option value="5">Option 5</option>
  229. <option value="6">Option 6</option>
  230. </select>
  231. </div>
  232. <div class="highlight">
  233. <pre class="prettyprint linenums">
  234. &lt;script type=&quot;text/javascript&quot;&gt;
  235. $('#example-multiple-selected').multiselect();
  236. &lt;/script&gt;
  237. &lt;!-- Note the missing multiple attribute! --&gt;
  238. &lt;select id="example-multiple-selected" multiple="multiple"&gt;
  239. &lt;option value="1"&gt;Option 1&lt;/option&gt;
  240. &lt;option value="2" selected="selected"&gt;Option 2&lt;/option&gt;
  241. &lt;!-- Option 3 will be selected in advance ... --&gt;
  242. &lt;option value="3" selected="selected"&gt;Option 3&lt;/option&gt;
  243. &lt;option value="4"&gt;Option 4&lt;/option&gt;
  244. &lt;option value="5"&gt;Option 5&lt;/option&gt;
  245. &lt;option value="6"&gt;Option 6&lt;/option&gt;
  246. &lt;/select&gt;
  247. </pre>
  248. <p>
  249. The plugin naturally supports <code>optgroup</code>'s, however the group headers are not clickable by default. See the <code>enableClickableOptGroups</code> option for details.
  250. </p>
  251. <div class="example">
  252. <script type="text/javascript">
  253. $(document).ready(function() {
  254. $('#example-multiple-optgroups').multiselect();
  255. });
  256. </script>
  257. <select id="example-multiple-optgroups" multiple="multiple">
  258. <optgroup label="Group 1">
  259. <option value="1-1">Option 1.1</option>
  260. <option value="1-2" selected="selected">Option 1.2</option>
  261. <option value="1-3" selected="selected">Option 1.3</option>
  262. </optgroup>
  263. <optgroup label="Group 2">
  264. <option value="2-1">Option 2.1</option>
  265. <option value="2-2">Option 2.2</option>
  266. <option value="2-3">Option 2.3</option>
  267. </optgroup>
  268. </select>
  269. </div>
  270. <div class="highlight">
  271. <pre class="prettyprint linenums">
  272. &lt;script type=&quot;text/javascript&quot;&gt;
  273. $('#example-multiple-optgroups').multiselect();
  274. &lt;/script&gt;
  275. &lt;select id=&quot;example-multiple-optgroups&quot;&gt;
  276. &lt;optgroup label=&quot;Group 1&quot;&gt;
  277. &lt;option value=&quot;1-1&quot;&gt;Option 1.1&lt;/option&gt;
  278. &lt;option value=&quot;1-2&quot; selected=&quot;selected&quot;&gt;Option 1.2&lt;/option&gt;
  279. &lt;option value=&quot;1-3&quot; selected=&quot;selected&quot;&gt;Option 1.3&lt;/option&gt;
  280. &lt;/optgroup&gt;
  281. &lt;optgroup label=&quot;Group 2&quot;&gt;
  282. &lt;option value=&quot;2-1&quot;&gt;Option 2.1&lt;/option&gt;
  283. &lt;option value=&quot;2-2&quot;&gt;Option 2.2&lt;/option&gt;
  284. &lt;option value=&quot;2-3&quot;&gt;Option 2.3&lt;/option&gt;
  285. &lt;/optgroup&gt;
  286. &lt;/select&gt;
  287. </pre>
  288. </div>
  289. </td>
  290. </tr>
  291. <tr>
  292. <td><code>enableHTML</code></td>
  293. <td>
  294. <p>
  295. XSS injection is a serious thread for all modern web applications. Setting <code>enableHTML</code> to <code>false</code> (default setting) will create a XSS save multiselect.
  296. </p>
  297. <div class="example">
  298. <script type="text/javascript">
  299. $(document).ready(function() {
  300. $('#example-xss').multiselect();
  301. });
  302. </script>
  303. <select id="example-xss" multiple="multiple">
  304. <option value="1">&lt;script&gt;alert(1);&lt;/script&gt;</option>
  305. </select>
  306. </div>
  307. <div class="highlight">
  308. <pre class="prettyprint linenums">
  309. &lt;script type="text/javascript"&gt;
  310. $(document).ready(function() {
  311. $('#example-xss').multiselect();
  312. });
  313. &lt;/script&gt;
  314. &lt;select id="example-xss" multiple="multiple"&gt;
  315. &lt;option value="1"&gt;&amp;lt;script&amp;gt;alert(1);&amp;lt;/script&amp;gt;&lt;/option&gt;
  316. &lt;/select&gt;
  317. </pre>
  318. <p>On the other hand, when setting <code>enableHTML</code> to <code>true</code>, the plugin will support HTML within <code>option</code>s:</p>
  319. <div class="example">
  320. <script type="text/javascript">
  321. $(document).ready(function() {
  322. $('#example-xss-html').multiselect({
  323. nonSelectedText: '<span style="color:red;">Non selected ...</span>',
  324. enableHTML: true
  325. });
  326. });
  327. </script>
  328. <select id="example-xss-html" multiple="multiple">
  329. <option value="1">&lt;span style=&quot;color:red&quot;&gt;Option 1&lt;/span&gt;</option>
  330. </select>
  331. </div>
  332. <div class="highlight">
  333. <pre class="prettyprint linenums">
  334. &lt;script type="text/javascript"&gt;
  335. $(doclect&gt;
  336. </pre>ument).ready(function() {
  337. $('#example-xss-html').multiselect();
  338. });
  339. &lt;/script&gt;
  340. &lt;select id="example-xss-html" multiple="multiple"&gt;
  341. &lt;option value="1"&gt;&amp;gt;span style="color:red"&amp;lt;Option 1&amp;gt;/span&amp;gt;&lt;/option&gt;
  342. &lt;/select&gt;
  343. </pre>
  344. </td>
  345. </tr>
  346. <tr>
  347. <td><code>enableClickableOptGroups</code></td>
  348. <td>
  349. <p>
  350. If set to <code>true</code>, <code>optgroup</code>'s will be clickable, allowing to easily select multiple options belonging to the same group.
  351. </p>
  352. <div class="example">
  353. <script type="text/javascript">
  354. $(document).ready(function() {
  355. $('#example-enableClickableOptGroups').multiselect({
  356. enableClickableOptGroups: true
  357. });
  358. });
  359. </script>
  360. <select id="example-enableClickableOptGroups" multiple="multiple">
  361. <optgroup label="Group 1">
  362. <option value="1-1">Option 1.1</option>
  363. <option value="1-2" selected="selected">Option 1.2</option>
  364. <option value="1-3" selected="selected">Option 1.3</option>
  365. </optgroup>
  366. <optgroup label="Group 2">
  367. <option value="2-1">Option 2.1</option>
  368. <option value="2-2">Option 2.2</option>
  369. <option value="2-3">Option 2.3</option>
  370. </optgroup>
  371. </select>
  372. </div>
  373. <div class="highlight">
  374. <pre class="prettyprint linenums">
  375. &lt;script type=&quot;text/javascript&quot;&gt;
  376. $(document).ready(function() {
  377. $('#example-enableClickableOptGroups').multiselect({
  378. enableClickableOptGroups: true
  379. });
  380. });
  381. &lt;/script&gt;
  382. </pre>
  383. </div>
  384. <p>
  385. Note that this option does also work with disabled options:
  386. </p>
  387. <div class="example">
  388. <script type="text/javascript">
  389. $(document).ready(function() {
  390. $('#example-enableClickableOptGroups-disabled').multiselect({
  391. enableClickableOptGroups: true,
  392. includeSelectAllOption: true
  393. });
  394. });
  395. </script>
  396. <select id="example-enableClickableOptGroups-disabled" multiple="multiple">
  397. <optgroup label="Group 1">
  398. <option value="1-1" disabled>Option 1.1</option>
  399. <option value="1-2" selected="selected">Option 1.2</option>
  400. <option value="1-3" selected="selected">Option 1.3</option>
  401. </optgroup>
  402. <optgroup label="Group 2">
  403. <option value="2-1" disabled>Option 2.1</option>
  404. <option value="2-2">Option 2.2</option>
  405. <option value="2-3">Option 2.3</option>
  406. </optgroup>
  407. </select>
  408. </div>
  409. <div class="highlight">
  410. <pre class="prettyprint linenums">
  411. &lt;script type=&quot;text/javascript&quot;&gt;
  412. $(document).ready(function() {
  413. $('#example-enableClickableOptGroups-disabled').multiselect({
  414. enableClickableOptGroups: true
  415. });
  416. });
  417. &lt;/script&gt;
  418. </pre>
  419. </td>
  420. </tr>
  421. <tr>
  422. <td>
  423. <code>enableCollapsibleOptGroups</code>
  424. </td>
  425. <td>
  426. <p class="alert alert-info">
  427. For this option to be available, <code>bootstrap-multiselect-collapsible-groups.js</code> needs to be included.
  428. </p>
  429. <p>
  430. Make your groups collapsible.
  431. </p>
  432. <div class="example">
  433. <script type="text/javascript">
  434. $(document).ready(function() {
  435. $('#example-enableCollapsibleOptGroups').multiselect({
  436. enableCollapsibleOptGroups: true
  437. });
  438. });
  439. </script>
  440. <select id="example-enableCollapsibleOptGroups" multiple="multiple">
  441. <optgroup label="Group 1">
  442. <option value="1-1" disabled>Option 1.1</option>
  443. <option value="1-2" selected="selected">Option 1.2</option>
  444. <option value="1-3" selected="selected">Option 1.3</option>
  445. </optgroup>
  446. <optgroup label="Group 2">
  447. <option value="2-1" disabled>Option 2.1</option>
  448. <option value="2-2">Option 2.2</option>
  449. <option value="2-3">Option 2.3</option>
  450. </optgroup>
  451. </select>
  452. </div>
  453. <div class="highlight">
  454. <pre class="prettyprint linenums">
  455. &lt;script type="text/javascript"&gt;
  456. $(document).ready(function() {
  457. $('#example-enableCollapsibleOptGroups').multiselect({
  458. enableCollapsibleOptGroups: true
  459. });
  460. });
  461. &lt;/script&gt;
  462. &lt;select id="example-enableCollapsibleOptGroups" multiple="multiple"&gt;
  463. &lt;optgroup label=&quot;Group 1&quot;&gt;
  464. &lt;option value=&quot;1-1&quot; disabled&gt;Option 1.1&lt;/option&gt;
  465. &lt;option value=&quot;1-2&quot; selected=&quot;selected&quot;&gt;Option 1.2&lt;/option&gt;
  466. &lt;option value=&quot;1-3&quot; selected=&quot;selected&quot;&gt;Option 1.3&lt;/option&gt;
  467. &lt;/optgroup&gt;
  468. &lt;optgroup label=&quot;Group 2&quot;&gt;
  469. &lt;option value=&quot;2-1&quot; disabled&gt;Option 2.1&lt;/option&gt;
  470. &lt;option value=&quot;2-2&quot;&gt;Option 2.2&lt;/option&gt;
  471. &lt;option value=&quot;2-3&quot;&gt;Option 2.3&lt;/option&gt;
  472. &lt;/optgroup&gt;
  473. &lt;/select&gt;
  474. </pre>
  475. </div>
  476. </td>
  477. </tr>
  478. <tr>
  479. <td><code>disableIfEmpty</code></td>
  480. <td>
  481. <p>
  482. If set to <code>true</code>, the multiselect will be disabled if no options are given.
  483. </p>
  484. <div class="example">
  485. <script type="text/javascript">
  486. $(document).ready(function() {
  487. $('#example-disableIfEmpty').multiselect({
  488. disableIfEmpty: true
  489. });
  490. });
  491. </script>
  492. <select id="example-disableIfEmpty" multiple="multiple"></select>
  493. </div>
  494. <div class="highlight">
  495. <pre class="prettyprint linenums">
  496. &lt;script type=&quot;text/javascript&quot;&gt;
  497. $(document).ready(function() {
  498. $('#example-disableIfEmpty').multiselect({
  499. disableIfEmpty: true
  500. });
  501. });
  502. &lt;/script&gt;
  503. </pre>
  504. </div>
  505. </td>
  506. </tr>
  507. <tr>
  508. <td><code>dropRight</code></td>
  509. <td>
  510. <p>
  511. The dropdown can also be dropped right.
  512. </p>
  513. <div class="example">
  514. <script type="text/javascript">
  515. $(document).ready(function() {
  516. $('#example-dropRight').multiselect({
  517. buttonWidth: '400px',
  518. dropRight: true
  519. });
  520. });
  521. </script>
  522. <select id="example-dropRight" multiple="multiple">
  523. <option value="1">Option 1</option>
  524. <option value="2">Option 2</option>
  525. <option value="3">Option 3</option>
  526. <option value="4">Option 4</option>
  527. <option value="5">Option 5</option>
  528. <option value="6">Option 6</option>
  529. </select>
  530. </div>
  531. <div class="highlight">
  532. <pre class="prettyprint linenums">
  533. &lt;script type=&quot;text/javascript&quot;&gt;
  534. $(document).ready(function() {
  535. $('#example-dropRight').multiselect({
  536. buttonWidth: '400px',
  537. dropRight: true
  538. });
  539. });
  540. &lt;/script&gt;
  541. </pre>
  542. </div>
  543. </td>
  544. </tr>
  545. <tr>
  546. <td><code>maxHeight</code></td>
  547. <td>
  548. <p>
  549. The maximum height of the dropdown. This is useful when using the plugin with plenty of options.
  550. </p>
  551. <div class="example">
  552. <p>
  553. The multiselect on the left uses <code>maxHeight</code> set to <code>200</code>. On the other hand, the multiselect on the right does not use <code>maxHeight</code>.
  554. </p>
  555. <script type="text/javascript">
  556. $(document).ready(function() {
  557. $('#example-with-maxHeight').multiselect({
  558. maxHeight: 200
  559. });
  560. });
  561. </script>
  562. <select id="example-with-maxHeight" multiple="multiple">
  563. <option value="1">Option 1</option>
  564. <option value="2">Option 2</option>
  565. <option value="3">Option 3</option>
  566. <option value="4">Option 4</option>
  567. <option value="5">Option 5</option>
  568. <option value="6">Option 6</option>
  569. <option value="7">Option 7</option>
  570. <option value="9">Option 8</option>
  571. <option value="9">Option 9</option>
  572. <option value="10">Option 10</option>
  573. <option value="11">Option 11</option>
  574. <option value="12">Option 12</option>
  575. <option value="13">Option 13</option>
  576. <option value="14">Option 14</option>
  577. <option value="15">Option 15</option>
  578. <option value="16">Option 16</option>
  579. <option value="17">Option 17</option>
  580. <option value="18">Option 18</option>
  581. <option value="19">Option 19</option>
  582. <option value="20">Option 20</option>
  583. </select>
  584. <script type="text/javascript">
  585. $(document).ready(function() {
  586. $('#example-without-maxHeight').multiselect();
  587. });
  588. </script>
  589. <select id="example-without-maxHeight" multiple="multiple">
  590. <option value="1">Option 1</option>
  591. <option value="2">Option 2</option>
  592. <option value="3">Option 3</option>
  593. <option value="4">Option 4</option>
  594. <option value="5">Option 5</option>
  595. <option value="6">Option 6</option>
  596. <option value="7">Option 7</option>
  597. <option value="9">Option 8</option>
  598. <option value="9">Option 9</option>
  599. <option value="10">Option 10</option>
  600. <option value="11">Option 11</option>
  601. <option value="12">Option 12</option>
  602. <option value="13">Option 13</option>
  603. <option value="14">Option 14</option>
  604. <option value="15">Option 15</option>
  605. <option value="16">Option 16</option>
  606. <option value="17">Option 17</option>
  607. <option value="18">Option 18</option>
  608. <option value="19">Option 19</option>
  609. <option value="20">Option 20</option>
  610. </select>
  611. </div>
  612. <div class="highlight">
  613. <pre class="prettyprint linenums">
  614. &lt;script type=&quot;text/javascript&quot;&gt;
  615. $(document).ready(function() {
  616. $('#example-with-maxHeight').multiselect({
  617. maxHeight: 200
  618. });
  619. });
  620. &lt;/script&gt;
  621. </pre>
  622. </div>
  623. </td>
  624. </tr>
  625. <tr>
  626. <td><code>checkboxName</code></td>
  627. <td>
  628. <p>
  629. The name used for the generated checkboxes. See <a href="#post">Server-Side Processing</a> for details.
  630. </p>
  631. <div class="example">
  632. <script type="text/javascript">
  633. $(document).ready(function() {
  634. $('#example-checkboxName').multiselect({
  635. checkboxName: 'multiselect[]'
  636. });
  637. });
  638. </script>
  639. <select id="example-checkboxName" multiple="multiple">
  640. <option value="1">Option 1</option>
  641. <option value="2">Option 2</option>
  642. <option value="3">Option 3</option>
  643. <option value="4">Option 4</option>
  644. <option value="5">Option 5</option>
  645. <option value="6">Option 6</option>
  646. </select>
  647. </div>
  648. <div class="highlight">
  649. <pre class="prettyprint linenums">
  650. &lt;script type=&quot;text/javascript&quot;&gt;
  651. $(document).ready(function() {
  652. $('#example-checkboxName').multiselect({
  653. checkboxName: 'multiselect[]'
  654. });
  655. });
  656. &lt;/script&gt;
  657. </pre>
  658. </div>
  659. </td>
  660. </tr>
  661. <tr>
  662. <td><code>onChange</code></td>
  663. <td>
  664. <p>
  665. A function which is triggered on the change event of the options. Note that the event is not triggered when selecting or deselecting options using the <code>select</code> and <code>deselect</code> methods provided by the plugin.
  666. </p>
  667. <div class="example">
  668. <script type="text/javascript">
  669. $(document).ready(function() {
  670. $('#example-onChange').multiselect({
  671. onChange: function(option, checked, select) {
  672. alert('Changed option ' + $(option).val() + '.');
  673. }
  674. });
  675. });
  676. </script>
  677. <select id="example-onChange" multiple="multiple">
  678. <option value="1">Option 1</option>
  679. <option value="2">Option 2</option>
  680. <option value="3">Option 3</option>
  681. <option value="4">Option 4</option>
  682. <option value="5">Option 5</option>
  683. <option value="6">Option 6</option>
  684. </select>
  685. </div>
  686. <div class="highlight">
  687. <pre class="prettyprint linenums">
  688. &lt;script type=&quot;text/javascript&quot;&gt;
  689. $(document).ready(function() {
  690. $('#example-onChange').multiselect({
  691. onChange: function(option, checked, select) {
  692. alert('Changed option ' + $(option).val() + '.');
  693. }
  694. });
  695. });
  696. &lt;/script&gt;
  697. </pre>
  698. </div>
  699. </td>
  700. </tr>
  701. <tr>
  702. <td><code>onDropdownShow</code></td>
  703. <td>
  704. <p>
  705. A callback called when the dropdown is shown.
  706. </p>
  707. <p class="alert alert-warning">
  708. The <code>onDropdownShow</code> option is not available when using Twitter Bootstrap 2.3.
  709. </p>
  710. <div class="example">
  711. <script type="text/javascript">
  712. $(document).ready(function() {
  713. $('#example-onDropdownShow').multiselect({
  714. onDropdownShow: function(event) {
  715. alert('Dropdown shown.');
  716. }
  717. });
  718. });
  719. </script>
  720. <select id="example-onDropdownShow" multiple="multiple">
  721. <option value="1">Option 1</option>
  722. <option value="2">Option 2</option>
  723. <option value="3">Option 3</option>
  724. <option value="4">Option 4</option>
  725. <option value="5">Option 5</option>
  726. <option value="6">Option 6</option>
  727. </select>
  728. </div>
  729. <div class="highlight">
  730. <pre class="prettyprint linenums">
  731. &lt;script type=&quot;text/javascript&quot;&gt;
  732. $(document).ready(function() {
  733. $('#example-onDropdownShow').multiselect({
  734. onDropdownShow: function(event) {
  735. alert('Dropdown shown.');
  736. }
  737. });
  738. });
  739. &lt;/script&gt;
  740. </pre>
  741. </div>
  742. </td>
  743. </tr>
  744. <tr>
  745. <td><code>onDropdownHide</code></td>
  746. <td>
  747. <p>
  748. A callback called when the dropdown is closed.
  749. </p>
  750. <p class="alert alert-warning">
  751. The <code>onDropdownHide</code> option is not available when using Twitter Bootstrap 2.3.
  752. </p>
  753. <div class="example">
  754. <script type="text/javascript">
  755. $(document).ready(function() {
  756. $('#example-onDropdownHide').multiselect({
  757. onDropdownHide: function(event) {
  758. alert('Dropdown closed.');
  759. }
  760. });
  761. });
  762. </script>
  763. <select id="example-onDropdownHide" multiple="multiple">
  764. <option value="1">Option 1</option>
  765. <option value="2">Option 2</option>
  766. <option value="3">Option 3</option>
  767. <option value="4">Option 4</option>
  768. <option value="5">Option 5</option>
  769. <option value="6">Option 6</option>
  770. </select>
  771. </div>
  772. <div class="highlight">
  773. <pre class="prettyprint linenums">
  774. &lt;script type=&quot;text/javascript&quot;&gt;
  775. $(document).ready(function() {
  776. $('#example-onDropdownHide').multiselect({
  777. onDropdownHide: function(event) {
  778. alert('Dropdown closed.');
  779. }
  780. });
  781. });
  782. &lt;/script&gt;
  783. </pre>
  784. </div>
  785. </td>
  786. </tr>
  787. <tr>
  788. <td><code>onDropdownShown</code></td>
  789. <td>
  790. <p>
  791. A callback called <i>after</i> the dropdown has been shown.
  792. </p>
  793. <p class="alert alert-warning">
  794. The <code>onDropdownShown</code> option is not available when using Twitter Bootstrap 2.3.
  795. </p>
  796. <div class="example">
  797. <script type="text/javascript">
  798. $(document).ready(function() {
  799. $('#example-onDropdownShown').multiselect({
  800. onDropdownShown: function(event) {
  801. alert('Dropdown shown.');
  802. }
  803. });
  804. });
  805. </script>
  806. <select id="example-onDropdownShown" multiple="multiple">
  807. <option value="1">Option 1</option>
  808. <option value="2">Option 2</option>
  809. <option value="3">Option 3</option>
  810. <option value="4">Option 4</option>
  811. <option value="5">Option 5</option>
  812. <option value="6">Option 6</option>
  813. </select>
  814. </div>
  815. <div class="highlight">
  816. <pre class="prettyprint linenums">
  817. &lt;script type=&quot;text/javascript&quot;&gt;
  818. $(document).ready(function() {
  819. $('#example-onDropdownShown').multiselect({
  820. onDropdownShown: function(event) {
  821. alert('Dropdown closed.');
  822. }
  823. });
  824. });
  825. &lt;/script&gt;
  826. </pre>
  827. </div>
  828. </td>
  829. </tr>
  830. <tr>
  831. <td><code>onDropdownHidden</code></td>
  832. <td>
  833. <p>
  834. A callback called <i>after</i> the dropdown has been closed.
  835. </p>
  836. <p class="alert alert-warning">
  837. The <code>onDropdownHidden</code> option is not available when using Twitter Bootstrap 2.3.
  838. </p>
  839. <div class="example">
  840. <script type="text/javascript">
  841. $(document).ready(function() {
  842. $('#example-onDropdownHidden').multiselect({
  843. onDropdownHidden: function(event) {
  844. alert('Dropdown closed.');
  845. }
  846. });
  847. });
  848. </script>
  849. <select id="example-onDropdownHidden" multiple="multiple">
  850. <option value="1">Option 1</option>
  851. <option value="2">Option 2</option>
  852. <option value="3">Option 3</option>
  853. <option value="4">Option 4</option>
  854. <option value="5">Option 5</option>
  855. <option value="6">Option 6</option>
  856. </select>
  857. </div>
  858. <div class="highlight">
  859. <pre class="prettyprint linenums">
  860. &lt;script type=&quot;text/javascript&quot;&gt;
  861. $(document).ready(function() {
  862. $('#example-ondropdownHidden').multiselect({
  863. onDropdownHidden: function(event) {
  864. alert('Dropdown closed.');
  865. }
  866. });
  867. });
  868. &lt;/script&gt;
  869. </pre>
  870. </div>
  871. </td>
  872. </tr>
  873. <tr>
  874. <td><code>buttonClass</code></td>
  875. <td>
  876. <p>
  877. The class of the multiselect button.
  878. </p>
  879. <div class="example">
  880. <script type="text/javascript">
  881. $(document).ready(function() {
  882. $('#example-buttonClass').multiselect({
  883. buttonClass: 'btn btn-link'
  884. });
  885. });
  886. </script>
  887. <select id="example-buttonClass" multiple="multiple">
  888. <option value="1">Option 1</option>
  889. <option value="2">Option 2</option>
  890. <option value="3">Option 3</option>
  891. <option value="4">Option 4</option>
  892. <option value="5">Option 5</option>
  893. <option value="6">Option 6</option>
  894. </select>
  895. </div>
  896. <div class="highlight">
  897. <pre class="prettyprint linenums">
  898. &lt;script type=&quot;text/javascript&quot;&gt;
  899. $(document).ready(function() {
  900. $('#example-buttonClass').multiselect({
  901. buttonClass: 'btn btn-link'
  902. });
  903. });
  904. &lt;/script&gt;
  905. </pre>
  906. </div>
  907. </td>
  908. </tr>
  909. <tr>
  910. <td><code>inheritClass</code></td>
  911. <td>
  912. <p>
  913. Inherit the class of the button from the original select.
  914. </p>
  915. <div class="example">
  916. <script type="text/javascript">
  917. $(document).ready(function() {
  918. $('#example-inheritButton').multiselect({
  919. inheritClass: true
  920. });
  921. });
  922. </script>
  923. <select id="example-inheritButton" class="btn-primary" multiple="multiple">
  924. <option value="1">Option 1</option>
  925. <option value="2">Option 2</option>
  926. <option value="3">Option 3</option>
  927. <option value="4">Option 4</option>
  928. <option value="5">Option 5</option>
  929. <option value="6">Option 6</option>
  930. </select>
  931. </div>
  932. <div class="highlight">
  933. <pre class="prettyprint linenums">
  934. &lt;script type=&quot;text/javascript&quot;&gt;
  935. $(document).ready(function() {
  936. $('#example-inheritButton').multiselect({
  937. inheritClass: true
  938. });
  939. });
  940. &lt;/script&gt;
  941. </pre>
  942. </div>
  943. </td>
  944. </tr>
  945. <tr>
  946. <td><code>buttonContainer</code></td>
  947. <td>
  948. <p>
  949. The container holding both the button as well as the dropdown.
  950. </p>
  951. <div class="example">
  952. <script type="text/javascript">
  953. $(document).ready(function() {
  954. $('#example-buttonContainer').multiselect({
  955. buttonContainer: '<div class="btn-group" />'
  956. });
  957. });
  958. </script>
  959. <select id="example-buttonContainer" multiple="multiple">
  960. <option value="1">Option 1</option>
  961. <option value="2">Option 2</option>
  962. <option value="3">Option 3</option>
  963. <option value="4">Option 4</option>
  964. <option value="5">Option 5</option>
  965. <option value="6">Option 6</option>
  966. </select>
  967. </div>
  968. <div class="highlight">
  969. <pre class="prettyprint linenums">
  970. &lt;script type=&quot;text/javascript&quot;&gt;
  971. $(document).ready(function() {
  972. $('#example-buttonContainer').multiselect({
  973. buttonContainer: '&lt;div class=&quot;btn-group&quot; /&gt;'
  974. });
  975. });
  976. &lt;/script&gt;
  977. </pre>
  978. </div>
  979. </td>
  980. </tr>
  981. <tr>
  982. <td><code>buttonWidth</code></td>
  983. <td>
  984. <p>
  985. The width of the multiselect button may be fixed using this option.
  986. </p>
  987. <div class="example">
  988. <script type="text/javascript">
  989. $(document).ready(function() {
  990. $('#example-buttonWidth').multiselect({
  991. buttonWidth: '400px'
  992. });
  993. });
  994. </script>
  995. <select id="example-buttonWidth" multiple="multiple">
  996. <option value="1">Option 1</option>
  997. <option value="2">Option 2</option>
  998. <option value="3">Option 3</option>
  999. <option value="4">Option 4</option>
  1000. <option value="5">Option 5</option>
  1001. <option value="6">Option 6</option>
  1002. </select>
  1003. </div>
  1004. <div class="highlight">
  1005. <pre class="prettyprint linenums">
  1006. &lt;script type=&quot;text/javascript&quot;&gt;
  1007. $(document).ready(function() {
  1008. $('#example-buttonWidth').multiselect({
  1009. buttonWidth: '400px'
  1010. });
  1011. });
  1012. &lt;/script&gt;
  1013. </pre>
  1014. </div>
  1015. <p>Note that if the text in the button title is too long, it will be truncated and use an ellipsis</p>
  1016. <div class="example">
  1017. <script type="text/javascript">
  1018. $(document).ready(function() {
  1019. $('#example-buttonWidth-overflow').multiselect({
  1020. buttonWidth: '150px'
  1021. });
  1022. });
  1023. </script>
  1024. <select id="example-buttonWidth-overflow" multiple="multiple">
  1025. <option value="1" selected>Option 1</option>
  1026. <option value="2" selected>Option 2</option>
  1027. <option value="3" selected>Option 3</option>
  1028. <option value="4">Option 4</option>
  1029. <option value="5">Option 5</option>
  1030. <option value="6">Option 6</option>
  1031. </select>
  1032. </div>
  1033. <div class="highlight">
  1034. <pre class="prettyprint linenums">
  1035. &lt;script type=&quot;text/javascript&quot;&gt;
  1036. $(document).ready(function() {
  1037. $('#example-buttonWidth-overflow').multiselect({
  1038. buttonWidth: '150px'
  1039. });
  1040. });
  1041. &lt;/script&gt;
  1042. </pre>
  1043. </div>
  1044. <p>
  1045. This does also work for long options:
  1046. </p>
  1047. <div class="example">
  1048. <script type="text/javascript">
  1049. $(document).ready(function() {
  1050. $('#example-buttonWidth-overflow-option').multiselect({
  1051. buttonWidth: '150px'
  1052. });
  1053. });
  1054. </script>
  1055. <select id="example-buttonWidth-overflow-option" multiple="multiple">
  1056. <option value="1" selected>Long Long Long Option 1</option>
  1057. <option value="2">Very Very Long Option 2</option>
  1058. <option value="3">Even Longer Option 3</option>
  1059. <option value="4">Ridiculous Long Option 4</option>
  1060. </select>
  1061. </div>
  1062. <div class="highlight">
  1063. <pre class="prettyprint linenums">
  1064. &lt;script type=&quot;text/javascript&quot;&gt;
  1065. $(document).ready(function() {
  1066. $('#example-buttonWidth-overflow').multiselect({
  1067. buttonWidth: '150px'
  1068. });
  1069. });
  1070. &lt;/script&gt;
  1071. </pre>
  1072. </div>
  1073. </td>
  1074. </tr>
  1075. <tr>
  1076. <td><code>buttonText</code></td>
  1077. <td>
  1078. <p>
  1079. A callback specifying the text shown on the button dependent on the currently selected options.
  1080. </p>
  1081. <p>
  1082. The callback gets the currently selected <code>options</code> and the <code>select</code> as argument and returns the string shown as button text. The default <code>buttonText</code> callback returns <code>nonSelectedText</code> in the case no option is selected, <code>nSelectedText</code> in the case more than <code>numberDisplayed</code> options are selected and the names of the selected options if less than <code>numberDisplayed</code> options are selected.
  1083. </p>
  1084. <div class="example">
  1085. <script type="text/javascript">
  1086. $(document).ready(function() {
  1087. $('#example-buttonText').multiselect({
  1088. buttonText: function(options, select) {
  1089. if (options.length === 0) {
  1090. return 'No option selected ...';
  1091. }
  1092. else if (options.length > 3) {
  1093. return 'More than 3 options selected!';
  1094. }
  1095. else {
  1096. var labels = [];
  1097. options.each(function() {
  1098. if ($(this).attr('label') !== undefined) {
  1099. labels.push($(this).attr('label'));
  1100. }
  1101. else {
  1102. labels.push($(this).html());
  1103. }
  1104. });
  1105. return labels.join(', ');
  1106. }
  1107. }
  1108. });
  1109. });
  1110. </script>
  1111. <select id="example-buttonText" multiple="multiple">
  1112. <option value="1">Option 1</option>
  1113. <option value="2">Option 2</option>
  1114. <option value="3">Option 3</option>
  1115. <option value="4">Option 4</option>
  1116. <option value="5">Option 5</option>
  1117. <option value="6">Option 6</option>
  1118. </select>
  1119. </div>
  1120. <div class="highlight">
  1121. <pre class="prettyprint linenums">
  1122. &lt;script type=&quot;text/javascript&quot;&gt;
  1123. $(document).ready(function() {
  1124. $('#example-buttonText').multiselect({
  1125. buttonText: function(options, select) {
  1126. if (options.length === 0) {
  1127. return 'No option selected ...';
  1128. }
  1129. else if (options.length > 3) {
  1130. return 'More than 3 options selected!';
  1131. }
  1132. else {
  1133. var labels = [];
  1134. options.each(function() {
  1135. if ($(this).attr('label') !== undefined) {
  1136. labels.push($(this).attr('label'));
  1137. }
  1138. else {
  1139. labels.push($(this).html());
  1140. }
  1141. });
  1142. return labels.join(', ') + '';
  1143. }
  1144. }
  1145. });
  1146. });
  1147. &lt;/script&gt;
  1148. </pre>
  1149. </div>
  1150. </td>
  1151. </tr>
  1152. <tr>
  1153. <td><code>buttonTitle</code></td>
  1154. <td>
  1155. <p>
  1156. A callback specifying the title of the button.
  1157. </p>
  1158. <p>
  1159. The callback gets the currently selected <code>options</code> and the <code>select</code> as argument and returns the title of the button as string. The default <code>buttonTitle</code> callback returns <code>nonSelectedText</code> in the case no option is selected and the names of the selected options of less than <code>numberDisplayed</code> options are selected. If more than <code>numberDisplayed</code> options are selected, <code>nSelectedText</code> is returned.
  1160. </p>
  1161. <div class="example">
  1162. <script type="text/javascript">
  1163. $(document).ready(function() {
  1164. $('#example-buttonTitle').multiselect({
  1165. buttonText: function(options, select) {
  1166. return 'Check the title!';
  1167. },
  1168. buttonTitle: function(options, select) {
  1169. var labels = [];
  1170. options.each(function () {
  1171. labels.push($(this).text());
  1172. });
  1173. return labels.join(' - ');
  1174. }
  1175. });
  1176. });
  1177. </script>
  1178. <select id="example-buttonTitle" multiple="multiple">
  1179. <option value="1">Option 1</option>
  1180. <option value="2">Option 2</option>
  1181. <option value="3">Option 3</option>
  1182. <option value="4">Option 4</option>
  1183. <option value="5">Option 5</option>
  1184. <option value="6">Option 6</option>
  1185. </select>
  1186. </div>
  1187. <div class="highlight">
  1188. <pre class="prettyprint linenums">
  1189. &lt;script type=&quot;text/javascript&quot;&gt;
  1190. $(document).ready(function() {
  1191. $('#example-buttonTitle').multiselect({
  1192. buttonText: function(options, select) {
  1193. return 'Check the title!';
  1194. },
  1195. buttonTitle: function(options, select) {
  1196. var labels = [];
  1197. options.each(function () {
  1198. labels.push($(this).text());
  1199. });
  1200. return labels.join(' - ');
  1201. }
  1202. });
  1203. });
  1204. &lt;/script&gt;
  1205. </pre>
  1206. </div>
  1207. </td>
  1208. </tr>
  1209. <tr>
  1210. <td><code>nonSelectedText</code></td>
  1211. <td>
  1212. <p>
  1213. The text displayed when no option is selected. This option is used in the default <code>buttonText</code> and <code>buttonTitle</code> functions.
  1214. </p>
  1215. <div class="example">
  1216. <script type="text/javascript">
  1217. $(document).ready(function() {
  1218. $('#example-nonSelectedText').multiselect({
  1219. nonSelectedText: 'Check an option!'
  1220. });
  1221. });
  1222. </script>
  1223. <select id="example-nonSelectedText" multiple="multiple">
  1224. <option value="1">Option 1</option>
  1225. <option value="2">Option 2</option>
  1226. <option value="3">Option 3</option>
  1227. <option value="4">Option 4</option>
  1228. <option value="5">Option 5</option>
  1229. <option value="6">Option 6</option>
  1230. </select>
  1231. </div>
  1232. <div class="highlight">
  1233. <pre class="prettyprint linenums">
  1234. &lt;script type=&quot;text/javascript&quot;&gt;
  1235. $(document).ready(function() {
  1236. $('#example-nonSelectedText').multiselect({
  1237. nonSelectedText: 'Check an option!'
  1238. });
  1239. });
  1240. &lt;/script&gt;
  1241. </pre>
  1242. </div>
  1243. </td>
  1244. </tr>
  1245. <tr>
  1246. <td><code>nSelectedText</code></td>
  1247. <td>
  1248. <p>
  1249. The text displayed if more than <code>numberDisplayed</code> options are selected. This option is used by the default <code>buttonText</code> and <code>buttonTitle</code> callbacks.
  1250. </p>
  1251. <div class="example">
  1252. <script type="text/javascript">
  1253. $(document).ready(function() {
  1254. $('#example-nSelectedText').multiselect({
  1255. nSelectedText: ' - Too many options selected!'
  1256. });
  1257. });
  1258. </script>
  1259. <select id="example-nSelectedText" multiple="multiple">
  1260. <option value="1">Option 1</option>
  1261. <option value="2">Option 2</option>
  1262. <option value="3">Option 3</option>
  1263. <option value="4">Option 4</option>
  1264. <option value="5">Option 5</option>
  1265. <option value="6">Option 6</option>
  1266. </select>
  1267. </div>
  1268. <div class="highlight">
  1269. <pre class="prettyprint linenums">
  1270. &lt;script type=&quot;text/javascript&quot;&gt;
  1271. $(document).ready(function() {
  1272. $('#example-nSelectedText').multiselect({
  1273. nSelectedText: ' - Too many options selected!'
  1274. });
  1275. });
  1276. &lt;/script&gt;
  1277. </pre>
  1278. </div>
  1279. </td>
  1280. </tr>
  1281. <tr>
  1282. <td><code>allSelectedText</code></td>
  1283. <td>
  1284. <p>
  1285. The text displayed if all options are selected.
  1286. </p>
  1287. <div class="example">
  1288. <script type="text/javascript">
  1289. $(document).ready(function() {
  1290. $('#example-allSelectedText').multiselect({
  1291. allSelectedText: 'No option left ...'
  1292. });
  1293. });
  1294. </script>
  1295. <select id="example-allSelectedText" multiple="multiple">
  1296. <option value="1">Option 1</option>
  1297. <option value="2">Option 2</option>
  1298. <option value="3">Option 3</option>
  1299. <option value="4">Option 4</option>
  1300. <option value="5">Option 5</option>
  1301. <option value="6">Option 6</option>
  1302. </select>
  1303. </div>
  1304. <div class="highlight">
  1305. <pre class="prettyprint linenums">
  1306. &lt;script type=&quot;text/javascript&quot;&gt;
  1307. $(document).ready(function() {
  1308. $('#example-allSelectedText').multiselect({
  1309. allSelectedText: 'No option left ...'
  1310. });
  1311. });
  1312. &lt;/script&gt;
  1313. </pre>
  1314. </div>
  1315. <p>
  1316. This option may be useful in combination with the <code>includeSelectAllOption</code>:
  1317. </p>
  1318. <div class="example">
  1319. <script type="text/javascript">
  1320. $(document).ready(function() {
  1321. $('#example-allSelectedText-includeSelectAllOption').multiselect({
  1322. includeSelectAllOption: true,
  1323. allSelectedText: 'No option left ...'
  1324. });
  1325. });
  1326. </script>
  1327. <select id="example-allSelectedText-includeSelectAllOption" multiple="multiple">
  1328. <option value="1">Option 1</option>
  1329. <option value="2">Option 2</option>
  1330. <option value="3">Option 3</option>
  1331. <option value="4">Option 4</option>
  1332. <option value="5">Option 5</option>
  1333. <option value="6">Option 6</option>
  1334. </select>
  1335. </div>
  1336. <div class="highlight">
  1337. <pre class="prettyprint linenums">
  1338. &lt;script type=&quot;text/javascript&quot;&gt;
  1339. $(document).ready(function() {
  1340. $('#example-allSelectedText-includeSelectAllOption').multiselect({
  1341. includeSelectAllOption: true,
  1342. allSelectedText: 'No option left ...'
  1343. });
  1344. });
  1345. &lt;/script&gt;
  1346. </pre>
  1347. </div>
  1348. </td>
  1349. </tr>
  1350. <tr>
  1351. <td><code>numberDisplayed</code></td>
  1352. <td>
  1353. <p>
  1354. This option is used by the <code>buttonText</code> and <code>buttonTitle</code> functions to determine of too much options would be displayed.
  1355. </p>
  1356. <div class="example">
  1357. <script type="text/javascript">
  1358. $(document).ready(function() {
  1359. $('#example-numberDisplayed').multiselect({
  1360. numberDisplayed: 1
  1361. });
  1362. });
  1363. </script>
  1364. <select id="example-numberDisplayed" multiple="multiple">
  1365. <option value="1">Option 1</option>
  1366. <option value="2">Option 2</option>
  1367. <option value="3">Option 3</option>
  1368. <option value="4">Option 4</option>
  1369. <option value="5">Option 5</option>
  1370. <option value="6">Option 6</option>
  1371. </select>
  1372. </div>
  1373. <div class="highlight">
  1374. <pre class="prettyprint linenums">
  1375. &lt;script type=&quot;text/javascript&quot;&gt;
  1376. $(document).ready(function() {
  1377. $('#example-numberDisplayed').multiselect({
  1378. numberDisplayed: 1
  1379. });
  1380. });
  1381. &lt;/script&gt;
  1382. </pre>
  1383. </div>
  1384. </td>
  1385. </tr>
  1386. <tr>
  1387. <td><code>delimiterText</code></td>
  1388. <td>
  1389. <p>
  1390. Sets the separator for the list of selected items for mouse-over. Defaults to ', '. Set to '\n' for a neater display.
  1391. </p>
  1392. <div class="example">
  1393. <script type="text/javascript">
  1394. $(document).ready(function() {
  1395. $('#example-delimiterText').multiselect({
  1396. delimiterText: '; '
  1397. });
  1398. });
  1399. </script>
  1400. <select id="example-delimiterText" multiple="multiple">
  1401. <option value="1">Option 1</option>
  1402. <option value="2" selected="selected">Option 2</option>
  1403. <option value="3" selected="selected">Option 3</option>
  1404. <option value="4">Option 4</option>
  1405. <option value="5">Option 5</option>
  1406. <option value="6">Option 6</option>
  1407. </select>
  1408. </div>
  1409. <div class="highlight">
  1410. <pre class="prettyprint linenums">
  1411. &lt;script type=&quot;text/javascript&quot;&gt;
  1412. $(document).ready(function() {
  1413. $('#example-delimiterText').multiselect({
  1414. delimiterText '; '
  1415. });
  1416. });
  1417. &lt;/script&gt;
  1418. </pre>
  1419. </div>
  1420. </td>
  1421. </tr>
  1422. <tr>
  1423. <td><code>optionLabel</code></td>
  1424. <td>
  1425. <p>
  1426. A callback used to define the labels of the options.
  1427. </p>
  1428. <div class="example">
  1429. <script type="text/javascript">
  1430. $(document).ready(function() {
  1431. $('#example-optionLabel').multiselect({
  1432. optionLabel: function(element) {
  1433. return $(element).html() + ' (' + $(element).val() + ')';
  1434. }
  1435. });
  1436. });
  1437. </script>
  1438. <select id="example-optionLabel" multiple="multiple">
  1439. <option value="option-1">Option 1</option>
  1440. <option value="option-2">Option 2</option>
  1441. <option value="option-3">Option 3</option>
  1442. <option value="option-4">Option 4</option>
  1443. <option value="option-5">Option 5</option>
  1444. <option value="option-6">Option 6</option>
  1445. </select>
  1446. </div>
  1447. <div class="highlight">
  1448. <pre class="prettyprint linenums">
  1449. &lt;script type=&quot;text/javascript&quot;&gt;
  1450. $(document).ready(function() {
  1451. $('#example-optionLabel').multiselect({
  1452. optionLabel: function(element) {
  1453. return $(element).html() + '(' + $(element).val() + ')';
  1454. }
  1455. });
  1456. });
  1457. &lt;/script&gt;
  1458. &lt;select id=&quot;example-label&quot; multiple=&quot;multiple&quot;&gt;
  1459. &lt;option value=&quot;option-1&quot;&gt;Option 1&lt;/option&gt;
  1460. &lt;option value=&quot;option-2&quot;&gt;Option 2&lt;/option&gt;
  1461. &lt;option value=&quot;option-3&quot;&gt;Option 3&lt;/option&gt;
  1462. &lt;option value=&quot;option-4&quot;&gt;Option 4&lt;/option&gt;
  1463. &lt;option value=&quot;option-5&quot;&gt;Option 5&lt;/option&gt;
  1464. &lt;option value=&quot;option-6&quot;&gt;Option 6&lt;/option&gt;
  1465. &lt;/select&gt;
  1466. </pre>
  1467. </div>
  1468. </td>
  1469. </tr>
  1470. <tr>
  1471. <td><code>selectedClass</code></td>
  1472. <td>
  1473. <p>
  1474. The class(es) applied on selected options.
  1475. </p>
  1476. <div class="example">
  1477. <style type="text/css">
  1478. #example-selectedClass-container li.multiselect-selected a label {
  1479. color: red;
  1480. }
  1481. </style>
  1482. <script type="text/javascript">
  1483. $(document).ready(function() {
  1484. $('#example-selectedClass').multiselect({
  1485. buttonContainer: '<div class="btn-group" id="example-selectedClass-container"></div>',
  1486. selectedClass: 'active multiselect-selected'
  1487. });
  1488. });
  1489. </script>
  1490. <select id="example-selectedClass" multiple="multiple">
  1491. <option value="1">Option 1</option>
  1492. <option value="2">Option 2</option>
  1493. <option value="3">Option 3</option>
  1494. <option value="4">Option 4</option>
  1495. <option value="5">Option 5</option>
  1496. <option value="6">Option 6</option>
  1497. </select>
  1498. </div>
  1499. <div class="highlight">
  1500. <pre class="prettyprint linenums">
  1501. &lt;style type="text/css"&gt;
  1502. #example-selectedClass-container li.multiselect-selected a label {
  1503. color: red;
  1504. }
  1505. &lt;/style&gt;
  1506. &lt;script type=&quot;text/javascript&quot;&gt;
  1507. $(document).ready(function() {
  1508. $('#example-selectedClass').multiselect({
  1509. buttonContainer: '&lt;div class=&quot;btn-group&quot; id=&quot;example-selectedClass-container&quot;&gt;&lt;/div&gt;',
  1510. selectedClass: 'multiselect-selected'
  1511. });
  1512. });
  1513. &lt;/script&gt;
  1514. </pre>
  1515. </div>
  1516. </td>
  1517. </tr>
  1518. <tr>
  1519. <td>
  1520. <code>includeSelectAllOption</code>
  1521. </td>
  1522. <td>
  1523. <p>
  1524. Set to <code>true</code> or <code>false</code> to enable or disable the select all option.
  1525. </p>
  1526. <p class="alert alert-info">
  1527. To see an example using both the select all option and the filter, see the documentation of the <code>enableFiltering</code> option.
  1528. </p>
  1529. <div class="example">
  1530. <script type="text/javascript">
  1531. $(document).ready(function() {
  1532. $('#example-includeSelectAllOption').multiselect({
  1533. includeSelectAllOption: true
  1534. });
  1535. });
  1536. </script>
  1537. <select id="example-includeSelectAllOption" multiple="multiple">
  1538. <option value="1">Option 1</option>
  1539. <option value="2">Option 2</option>
  1540. <option value="3">Option 3</option>
  1541. <option value="4">Option 4</option>
  1542. <option value="5">Option 5</option>
  1543. <option value="6">Option 6</option>
  1544. </select>
  1545. </div>
  1546. <div class="highlight">
  1547. <pre class="prettyprint linenums">
  1548. &lt;script type=&quot;text/javascript&quot;&gt;
  1549. $(document).ready(function() {
  1550. $('#example-includeSelectAllOption').multiselect({
  1551. includeSelectAllOption: true
  1552. });
  1553. });
  1554. &lt;/script&gt;
  1555. </pre>
  1556. </div>
  1557. <p>
  1558. The <code>includeSelectAllOption</code> option can also be used in combination with <code>optgroup</code>'s.
  1559. </p>
  1560. <div class="example">
  1561. <script type="text/javascript">
  1562. $(document).ready(function() {
  1563. $('#example-includeSelectAllOption-optgroups').multiselect({
  1564. includeSelectAllOption: true
  1565. });
  1566. });
  1567. </script>
  1568. <select id="example-includeSelectAllOption-optgroups" multiple="multiple">
  1569. <optgroup label="Group 1">
  1570. <option value="1-1">Option 1.1</option>
  1571. <option value="1-2" selected="selected">Option 1.2</option>
  1572. <option value="1-3" selected="selected">Option 1.3</option>
  1573. </optgroup>
  1574. <optgroup label="Group 2">
  1575. <option value="2-1">Option 2.1</option>
  1576. <option value="2-2">Option 2.2</option>
  1577. <option value="2-3">Option 2.3</option>
  1578. </optgroup>
  1579. </select>
  1580. </div>
  1581. <div class="highlight">
  1582. <pre class="prettyprint linenums">
  1583. &lt;script type=&quot;text/javascript&quot;&gt;
  1584. $(document).ready(function() {
  1585. $('#example-includeSelectAllOption-optgroups').multiselect({
  1586. includeSelectAllOption: true
  1587. });
  1588. });
  1589. &lt;/script&gt;
  1590. </pre>
  1591. </div>
  1592. </td>
  1593. </tr>
  1594. <tr>
  1595. <td>
  1596. <code>selectAllText</code>
  1597. </td>
  1598. <td>
  1599. <p>
  1600. The text displayed for the select all option.
  1601. </p>
  1602. <div class="example">
  1603. <script type="text/javascript">
  1604. $(document).ready(function() {
  1605. $('#example-selectAllText').multiselect({
  1606. includeSelectAllOption: true,
  1607. selectAllText: 'Check all!'
  1608. });
  1609. });
  1610. </script>
  1611. <select id="example-selectAllText" multiple="multiple">
  1612. <option value="1">Option 1</option>
  1613. <option value="2">Option 2</option>
  1614. <option value="3">Option 3</option>
  1615. <option value="4">Option 4</option>
  1616. <option value="5">Option 5</option>
  1617. <option value="6">Option 6</option>
  1618. </select>
  1619. </div>
  1620. <div class="highlight">
  1621. <pre class="prettyprint linenums">
  1622. &lt;script type=&quot;text/javascript&quot;&gt;
  1623. $(document).ready(function() {
  1624. $('#example-selectAllText').multiselect({
  1625. includeSelectAllOption: true,
  1626. selectAllText: 'Check all!'
  1627. });
  1628. });
  1629. &lt;/script&gt;
  1630. </pre>
  1631. </div>
  1632. </td>
  1633. </tr>
  1634. <tr>
  1635. <td>
  1636. <code>selectAllValue</code>
  1637. </td>
  1638. <td>
  1639. <p>
  1640. The select all option is added as additional <code>option</code> within the <code>select</code>. To distinguish this option from the original options the value used for the select all option can be configured using the <code>selectAllValue</code> option.
  1641. </p>
  1642. <div class="example">
  1643. <script type="text/javascript">
  1644. $(document).ready(function() {
  1645. $('#example-selectAllValue').multiselect({
  1646. includeSelectAllOption: true,
  1647. selectAllValue: 'select-all-value'
  1648. });
  1649. });
  1650. </script>
  1651. <select id="example-selectAllValue" multiple="multiple">
  1652. <option value="1">Option 1</option>
  1653. <option value="2">Option 2</option>
  1654. <option value="3">Option 3</option>
  1655. <option value="4">Option 4</option>
  1656. <option value="5">Option 5</option>
  1657. <option value="6">Option 6</option>
  1658. </select>
  1659. </div>
  1660. <div class="highlight">
  1661. <pre class="prettyprint linenums">
  1662. &lt;script type=&quot;text/javascript&quot;&gt;
  1663. $(document).ready(function() {
  1664. $('#example-selectAllValue').multiselect({
  1665. includeSelectAllOption: true,
  1666. selectAllValue: 'select-all-value'
  1667. });
  1668. });
  1669. &lt;/script&gt;
  1670. </pre>
  1671. </div>
  1672. <p>The <code>selectAllValue</code> option should usually be a string, however, numeric values work as well:</p>
  1673. <div class="example">
  1674. <script type="text/javascript">
  1675. $(document).ready(function() {
  1676. $('#example-selectAllValue-numeric').multiselect({
  1677. includeSelectAllOption: true,
  1678. selectAllValue: 0
  1679. });
  1680. });
  1681. </script>
  1682. <select id="example-selectAllValue-numeric" multiple="multiple">
  1683. <option value="1">Option 1</option>
  1684. <option value="2">Option 2</option>
  1685. <option value="3">Option 3</option>
  1686. <option value="4">Option 4</option>
  1687. <option value="5">Option 5</option>
  1688. <option value="6">Option 6</option>
  1689. </select>
  1690. </div>
  1691. <div class="highlight">
  1692. <pre class="prettyprint linenums">
  1693. &lt;script type=&quot;text/javascript&quot;&gt;
  1694. $(document).ready(function() {
  1695. $('#example-selectAllValue-numeric').multiselect({
  1696. includeSelectAllOption: true,
  1697. selectAllValue: 0
  1698. });
  1699. });
  1700. &lt;/script&gt;
  1701. </pre>
  1702. </div>
  1703. </td>
  1704. </tr>
  1705. <tr>
  1706. <td>
  1707. <code>selectAllName</code>
  1708. </td>
  1709. <td>
  1710. <p>
  1711. This option allows to control the name given to the select all option. See <a href="#post">Server-Side Processing</a> for more details.
  1712. </p>
  1713. <div class="example">
  1714. <script type="text/javascript">
  1715. $(document).ready(function() {
  1716. $('#example-selectAllName').multiselect({
  1717. includeSelectAllOption: true,
  1718. selectAllName: 'select-all-name'
  1719. });
  1720. });
  1721. </script>
  1722. <select id="example-selectAllName" multiple="multiple">
  1723. <option value="1">Option 1</option>
  1724. <option value="2">Option 2</option>
  1725. <option value="3">Option 3</option>
  1726. <option value="4">Option 4</option>
  1727. <option value="5">Option 5</option>
  1728. <option value="6">Option 6</option>
  1729. </select>
  1730. </div>
  1731. <div class="highlight">
  1732. <pre class="prettyprint linenums">
  1733. &lt;script type=&quot;text/javascript&quot;&gt;
  1734. $(document).ready(function() {
  1735. $('#example-selectAllName').multiselect({
  1736. includeSelectAllOption: true,
  1737. selectAllName: 'select-all-name'
  1738. });
  1739. });
  1740. &lt;/script&gt;
  1741. </pre>
  1742. </div>
  1743. </td>
  1744. </tr>
  1745. <tr>
  1746. <td>
  1747. <code>selectAllNumber</code>
  1748. </td>
  1749. <td>
  1750. <p>
  1751. If set to <code>true</code> (default), the number of selected options will be shown in parantheses when all options are seleted. The below example shows the behavior of the selectalloption with <code>selectAllNumber</code> set to <code>false</code>:
  1752. </p>
  1753. <div class="example">
  1754. <script type="text/javascript">
  1755. $(document).ready(function() {
  1756. $('#example-selectAllNumber').multiselect({
  1757. includeSelectAllOption: true,
  1758. selectAllNumber: false
  1759. });
  1760. });
  1761. </script>
  1762. <select id="example-selectAllNumber" multiple="multiple">
  1763. <option value="1">Option 1</option>
  1764. <option value="2">Option 2</option>
  1765. <option value="3">Option 3</option>
  1766. <option value="4">Option 4</option>
  1767. <option value="5">Option 5</option>
  1768. <option value="6">Option 6</option>
  1769. </select>
  1770. </div>
  1771. <div class="highlight">
  1772. <pre class="prettyprint linenums">
  1773. &lt;script type=&quot;text/javascript&quot;&gt;
  1774. $(document).ready(function() {
  1775. $('#example-selectAllNumber').multiselect({
  1776. includeSelectAllOption: true,
  1777. selectAllNumber: false
  1778. });
  1779. });
  1780. &lt;/script&gt;
  1781. </pre>
  1782. </div>
  1783. </td>
  1784. </tr>
  1785. <tr>
  1786. <td>
  1787. <code>onSelectAll</code>
  1788. </td>
  1789. <td>
  1790. <p>
  1791. This function is triggered when the select all option is used to select all options. Note that this can also be triggered manually using the <code>.multiselect('selectAll')</code> method.
  1792. </p>
  1793. <div class="example">
  1794. <script type="text/javascript">
  1795. $(document).ready(function() {
  1796. $('#example-onSelectAll').multiselect({
  1797. includeSelectAllOption: true,
  1798. onSelectAll: function() {
  1799. alert('onSelectAll triggered.');
  1800. }
  1801. });
  1802. });
  1803. </script>
  1804. <select id="example-onSelectAll" multiple="multiple">
  1805. <option value="1">Option 1</option>
  1806. <option value="2">Option 2</option>
  1807. <option value="3">Option 3</option>
  1808. <option value="4">Option 4</option>
  1809. <option value="5">Option 5</option>
  1810. <option value="6">Option 6</option>
  1811. </select>
  1812. </div>
  1813. <div class="highlight">
  1814. <pre class="prettyprint linenums">
  1815. &lt;script type=&quot;text/javascript&quot;&gt;
  1816. $('#example-onSelectAll').multiselect({
  1817. includeSelectAllOption: true,
  1818. onSelectAll: function() {
  1819. alert('onSelectAll triggered.');
  1820. }
  1821. });
  1822. &lt;/script&gt;
  1823. </pre>
  1824. </div>
  1825. </td>
  1826. </tr>
  1827. <tr>
  1828. <td>
  1829. <code>enableFiltering</code>
  1830. </td>
  1831. <td>
  1832. <p>
  1833. Set to <code>true</code> or <code>false</code> to enable or disable the filter. A filter <code>input</code> will be added to dynamically filter all options.
  1834. </p>
  1835. <div class="example">
  1836. <script type="text/javascript">
  1837. $(document).ready(function() {
  1838. $('#example-enableFiltering').multiselect({
  1839. enableFiltering: true
  1840. });
  1841. });
  1842. </script>
  1843. <select id="example-enableFiltering" multiple="multiple">
  1844. <option value="1">Option 1</option>
  1845. <option value="2">Option 2</option>
  1846. <option value="3">Option 3</option>
  1847. <option value="4">Option 4</option>
  1848. <option value="5">Option 5</option>
  1849. <option value="6">Option 6</option>
  1850. <option value="7">Option 7</option>
  1851. <option value="8">Option 8</option>
  1852. <option value="9">Option 9</option>
  1853. <option value="10">Option 10</option>
  1854. <option value="11">Option 11</option>
  1855. <option value="12">Option 12</option>
  1856. <option value="13">Option 13</option>
  1857. <option value="14">Option 14</option>
  1858. <option value="15">Option 15</option>
  1859. </select>
  1860. </div>
  1861. <div class="highlight">
  1862. <pre class="prettyprint linenums">
  1863. &lt;script type=&quot;text/javascript&quot;&gt;
  1864. $(document).ready(function() {
  1865. $('#example-enableFiltering').multiselect({
  1866. enableFiltering: true
  1867. });
  1868. });
  1869. &lt;/script&gt;
  1870. </pre>
  1871. </div>
  1872. <p>
  1873. The <code>enableFiltering</code> option can easily be used in combination with the <code>includeSelectAllOption</code> option:
  1874. </p>
  1875. <div class="example">
  1876. <script type="text/javascript">
  1877. $(document).ready(function() {
  1878. $('#example-enableFiltering-includeSelectAllOption').multiselect({
  1879. includeSelectAllOption: true,
  1880. enableFiltering: true
  1881. });
  1882. });
  1883. </script>
  1884. <select id="example-enableFiltering-includeSelectAllOption" multiple="multiple">
  1885. <option value="1">Option 1</option>
  1886. <option value="2">Option 2</option>
  1887. <option value="3">Option 3</option>
  1888. <option value="4">Option 4</option>
  1889. <option value="5">Option 5</option>
  1890. <option value="6">Option 6</option>
  1891. <option value="7">Option 7</option>
  1892. <option value="8">Option 8</option>
  1893. <option value="9">Option 9</option>
  1894. <option value="10">Option 10</option>
  1895. <option value="11">Option 11</option>
  1896. <option value="12">Option 12</option>
  1897. <option value="13">Option 13</option>
  1898. <option value="14">Option 14</option>
  1899. <option value="15">Option 15</option>
  1900. </select>
  1901. </div>
  1902. <div class="highlight">
  1903. <pre class="prettyprint linenums">
  1904. &lt;script type=&quot;text/javascript&quot;&gt;
  1905. $(document).ready(function() {
  1906. $('#example-enableFiltering-includeSelectAllOption').multiselect({
  1907. includeSelectAllOption: true,
  1908. enableFiltering: true
  1909. });
  1910. });
  1911. &lt;/script&gt;
  1912. </pre>
  1913. </div>
  1914. <p>
  1915. The <code>enableFiltering</code> option can also be used in combination with <code>optgroup</code>'s.
  1916. </p>
  1917. <div class="example">
  1918. <script type="text/javascript">
  1919. $(document).ready(function() {
  1920. $('#example-enableFiltering-optgroups').multiselect({
  1921. enableFiltering: true
  1922. });
  1923. });
  1924. </script>
  1925. <select id="example-enableFiltering-optgroups" multiple="multiple">
  1926. <optgroup label="Group 1">
  1927. <option value="1-1">Option 1.1</option>
  1928. <option value="1-2" selected="selected">Option 1.2</option>
  1929. <option value="1-3" selected="selected">Option 1.3</option>
  1930. </optgroup>
  1931. <optgroup label="Group 2">
  1932. <option value="2-1">Option 2.1</option>
  1933. <option value="2-2">Option 2.2</option>
  1934. <option value="2-3">Option 2.3</option>
  1935. </optgroup>
  1936. </select>
  1937. </div>
  1938. <div class="highlight">
  1939. <pre class="prettyprint linenums">
  1940. &lt;script type=&quot;text/javascript&quot;&gt;
  1941. $(document).ready(function() {
  1942. $('#example-example-enableFiltering-optgroups').multiselect({
  1943. enableFiltering: true
  1944. });
  1945. });
  1946. &lt;/script&gt;
  1947. </pre>
  1948. </div>
  1949. <p>
  1950. Clickable <code>optgroup</code>'s are also supported:
  1951. </p>
  1952. <div class="example">
  1953. <script type="text/javascript">
  1954. $(document).ready(function() {
  1955. $('#example-enableFiltering-enableClickableOptGroups').multiselect({
  1956. enableFiltering: true,
  1957. enableClickableOptGroups: true
  1958. });
  1959. });
  1960. </script>
  1961. <select id="example-enableFiltering-enableClickableOptGroups" multiple="multiple">
  1962. <optgroup label="Group 1">
  1963. <option value="1-1">Option 1.1</option>
  1964. <option value="1-2" selected="selected">Option 1.2</option>
  1965. <option value="1-3" selected="selected">Option 1.3</option>
  1966. </optgroup>
  1967. <optgroup label="Group 2">
  1968. <option value="2-1">Option 2.1</option>
  1969. <option value="2-2">Option 2.2</option>
  1970. <option value="2-3">Option 2.3</option>
  1971. </optgroup>
  1972. </select>
  1973. </div>
  1974. <div class="highlight">
  1975. <pre class="prettyprint linenums">
  1976. &lt;script type=&quot;text/javascript&quot;&gt;
  1977. $(document).ready(function() {
  1978. $('#example-example-enableFiltering-enableClickableOptgroups').multiselect({
  1979. enableFiltering: true,
  1980. enableClickableOptGroups: true
  1981. });
  1982. });
  1983. &lt;/script&gt;
  1984. </pre>
  1985. </div>
  1986. <p>
  1987. Finally, the option can also be used together with <code>onChange</code> or similar events:
  1988. </p>
  1989. <div class="example">
  1990. <script type="text/javascript">
  1991. $(document).ready(function() {
  1992. $('#example-enableFiltering-onChange-onDropdownHide').multiselect({
  1993. enableFiltering: true,
  1994. onChange: function(option, checked) {
  1995. alert('onChange!');
  1996. },
  1997. onDropdownHide: function(event) {
  1998. alert('onDropdownHide!');
  1999. }
  2000. });
  2001. });
  2002. </script>
  2003. <select id="example-enableFiltering-onChange-onDropdownHide" multiple="multiple">
  2004. <option value="1">Option 1</option>
  2005. <option value="2">Option 2</option>
  2006. <option value="3">Option 3</option>
  2007. <option value="4">Option 4</option>
  2008. <option value="5">Option 5</option>
  2009. <option value="6">Option 6</option>
  2010. <option value="7">Option 7</option>
  2011. <option value="8">Option 8</option>
  2012. <option value="9">Option 9</option>
  2013. <option value="10">Option 10</option>
  2014. <option value="11">Option 11</option>
  2015. <option value="12">Option 12</option>
  2016. <option value="13">Option 13</option>
  2017. <option value="14">Option 14</option>
  2018. <option value="15">Option 15</option>
  2019. </select>
  2020. </div>
  2021. <div class="highlight">
  2022. <pre class="prettyprint linenums">
  2023. &lt;script type=&quot;text/javascript&quot;&gt;
  2024. $(document).ready(function() {
  2025. $('#example-enableFiltering-onChange-onDropdownHide').multiselect({
  2026. enableFiltering: true,
  2027. onChange: function(option, checked) {
  2028. alert('onChange!');
  2029. },
  2030. onDropdownHide: function(event) {
  2031. alert('onDropdownHide!');
  2032. }
  2033. });
  2034. });
  2035. &lt;/script&gt;
  2036. </pre>
  2037. </div>
  2038. </td>
  2039. </tr>
  2040. <tr>
  2041. <td>
  2042. <code>enableCaseInsensitiveFiltering</code>
  2043. </td>
  2044. <td>
  2045. <p>
  2046. The filter as configured above will use case sensitive filtering, by setting <code>enableCaseInsensitiveFiltering</code> to <code>true</code> this behavior can be changed to use case insensitive filtering.
  2047. </p>
  2048. <div class="example">
  2049. <script type="text/javascript">
  2050. $(document).ready(function() {
  2051. $('#example-enableCaseInsensitiveFiltering').multiselect({
  2052. enableCaseInsensitiveFiltering: true
  2053. });
  2054. });
  2055. </script>
  2056. <select id="example-enableCaseInsensitiveFiltering" multiple="multiple">
  2057. <option value="1">OpTiOn 1</option>
  2058. <option value="2">OpTiOn 2</option>
  2059. <option value="3">OpTiOn 3</option>
  2060. <option value="4">OpTiOn 4</option>
  2061. <option value="5">OpTiOn 5</option>
  2062. <option value="6">OpTiOn 6</option>
  2063. <option value="7">OpTiOn 7</option>
  2064. <option value="8">OpTiOn 8</option>
  2065. <option value="9">OpTiOn 9</option>
  2066. <option value="10">OpTiOn 10</option>
  2067. <option value="11">OpTiOn 11</option>
  2068. <option value="12">OpTiOn 12</option>
  2069. <option value="13">OpTiOn 13</option>
  2070. <option value="14">OpTiOn 14</option>
  2071. <option value="15">OpTiOn 15</option>
  2072. </select>
  2073. </div>
  2074. <div class="highlight">
  2075. <pre class="prettyprint linenums">
  2076. &lt;script type=&quot;text/javascript&quot;&gt;
  2077. $(document).ready(function() {
  2078. $('#example-enableCaseInsensitiveFiltering').multiselect({
  2079. enableCaseInsensitiveFiltering: true
  2080. });
  2081. });
  2082. &lt;/script&gt;
  2083. </pre>
  2084. </div>
  2085. </td>
  2086. </tr>
  2087. <tr>
  2088. <td>
  2089. <code>filterBehavior</code>
  2090. </td>
  2091. <td>
  2092. <p>
  2093. The options are filtered based on their <code>text</code>. This behavior can be changed to use the <code>value</code> of the options or <code>both</code> the text and the value.
  2094. </p>
  2095. <div class="example">
  2096. <script type="text/javascript">
  2097. $(document).ready(function() {
  2098. $('#example-filterBehavior').multiselect({
  2099. enableFiltering: true,
  2100. filterBehavior: 'value'
  2101. });
  2102. });
  2103. </script>
  2104. <p>
  2105. In this example, the options have values from <code>a</code> to <code>n</code>. Instead of searching the text of the options, the value of the options is searched.
  2106. </p>
  2107. <select id="example-filterBehavior" multiple="multiple">
  2108. <option value="a">Option 1</option>
  2109. <option value="b">Option 2</option>
  2110. <option value="c">Option 3</option>
  2111. <option value="d">Option 4</option>
  2112. <option value="e">Option 5</option>
  2113. <option value="f">Option 6</option>
  2114. <option value="g">Option 7</option>
  2115. <option value="h">Option 8</option>
  2116. <option value="i">Option 9</option>
  2117. <option value="j">Option 10</option>
  2118. <option value="k">Option 11</option>
  2119. <option value="l">Option 12</option>
  2120. <option value="m">Option 13</option>
  2121. <option value="n">Option 14</option>
  2122. </select>
  2123. </div>
  2124. <div class="highlight">
  2125. <pre class="prettyprint linenums">
  2126. &lt;script type=&quot;text/javascript&quot;&gt;
  2127. $(document).ready(function() {
  2128. $('#example-filterBehavior').multiselect({
  2129. enableFiltering: true,
  2130. filterBehavior: 'value'
  2131. });
  2132. });
  2133. &lt;/script&gt;
  2134. &lt;select id="example-filterBehavior" multiple="multiple"&gt;
  2135. &lt;option value=&quot;a"&gt;Option 1&lt;/option&gt;
  2136. &lt;option value="b"&gt;Option 2&lt;/option&gt;
  2137. &lt;option value="c"&gt;Option 3&lt;/option&gt;
  2138. &lt;option value="d"&gt;Option 4&lt;/option&gt;
  2139. &lt;option value="e"&gt;Option 5&lt;/option&gt;
  2140. &lt;option value="f"&gt;Option 6&lt;/option&gt;
  2141. &lt;option value="g"&gt;Option 7&lt;/option&gt;
  2142. &lt;option value="h"&gt;Option 8&lt;/option&gt;
  2143. &lt;option value="i"&gt;Option 9&lt;/option&gt;
  2144. &lt;option value="j"&gt;Option 10&lt;/option&gt;
  2145. &lt;option value="k"&gt;Option 11&lt;/option&gt;
  2146. &lt;option value="l"&gt;Option 12&lt;/option&gt;
  2147. &lt;option value="m"&gt;Option 13&lt;/option&gt;
  2148. &lt;option value="n"&gt;Option 14&lt;/option&gt;
  2149. &lt;/select&gt;
  2150. </pre>
  2151. </div>
  2152. </td>
  2153. </tr>
  2154. <tr>
  2155. <td>
  2156. <code>filterPlaceholder</code>
  2157. </td>
  2158. <td>
  2159. <p>
  2160. The placeholder used for the filter input.
  2161. </p>
  2162. <div class="example">
  2163. <script type="text/javascript">
  2164. $(document).ready(function() {
  2165. $('#example-filter-placeholder').multiselect({
  2166. enableFiltering: true,
  2167. filterPlaceholder: 'Search for something...'
  2168. });
  2169. });
  2170. </script>
  2171. <select id="example-filter-placeholder" multiple="multiple">
  2172. <option value="a">Option 1</option>
  2173. <option value="b">Option 2</option>
  2174. <option value="c">Option 3</option>
  2175. <option value="d">Option 4</option>
  2176. <option value="e">Option 5</option>
  2177. <option value="f">Option 6</option>
  2178. <option value="g">Option 7</option>
  2179. <option value="h">Option 8</option>
  2180. <option value="i">Option 9</option>
  2181. <option value="j">Option 10</option>
  2182. <option value="k">Option 11</option>
  2183. <option value="l">Option 12</option>
  2184. <option value="m">Option 13</option>
  2185. <option value="n">Option 14</option>
  2186. </select>
  2187. </div>
  2188. <div class="highlight">
  2189. <pre class="prettyprint linenums">
  2190. &lt;script type=&quot;text/javascript&quot;&gt;
  2191. $(document).ready(function() {
  2192. $('#example-filter-placeholder').multiselect({
  2193. enableFiltering: true,
  2194. filterPlaceholder: 'Search for something...'
  2195. });
  2196. });
  2197. &lt;/script&gt;
  2198. &lt;select id="example-filterBehavior" multiple="multiple"&gt;
  2199. &lt;option value=&quot;a"&gt;Option 1&lt;/option&gt;
  2200. &lt;option value="b"&gt;Option 2&lt;/option&gt;
  2201. &lt;option value="c"&gt;Option 3&lt;/option&gt;
  2202. &lt;option value="d"&gt;Option 4&lt;/option&gt;
  2203. &lt;option value="e"&gt;Option 5&lt;/option&gt;
  2204. &lt;option value="f"&gt;Option 6&lt;/option&gt;
  2205. &lt;option value="g"&gt;Option 7&lt;/option&gt;
  2206. &lt;option value="h"&gt;Option 8&lt;/option&gt;
  2207. &lt;option value="i"&gt;Option 9&lt;/option&gt;
  2208. &lt;option value="j"&gt;Option 10&lt;/option&gt;
  2209. &lt;option value="k"&gt;Option 11&lt;/option&gt;
  2210. &lt;option value="l"&gt;Option 12&lt;/option&gt;
  2211. &lt;option value="m"&gt;Option 13&lt;/option&gt;
  2212. &lt;option value="n"&gt;Option 14&lt;/option&gt;
  2213. &lt;/select&gt;
  2214. </pre>
  2215. </div>
  2216. </td>
  2217. </tr>
  2218. </tbody>
  2219. </table>
  2220. <div class="page-header">
  2221. <h2 id="templates">Templates</h2>
  2222. </div>
  2223. <p>
  2224. The generated HTML markup can be controlled using templates. Basically, templates are simple configuration options. The default templates are shown below:
  2225. </p>
  2226. <p class="alert alert-warning">
  2227. However, note that messing with the template's classes may cause unexpected behavior. For example the button should always have the class <code>.multiselect</code>,
  2228. </p>
  2229. <p class="alert alert-info">
  2230. In addition, note that other options may also have influence on the templates, for example the <code>buttonClass</code> option.
  2231. </p>
  2232. <pre class="prettyprint linenums">
  2233. &lt;script type=&quot;text/javascript&quot;&gt;
  2234. $(document).ready(function() {
  2235. $('#example').multiselect({
  2236. templates: {
  2237. button: '&lt;button type=&quot;button&quot; class=&quot;multiselect dropdown-toggle&quot; data-toggle=&quot;dropdown&quot;&gt;&lt;/button&gt;',
  2238. ul: '&lt;ul class=&quot;multiselect-container dropdown-menu&quot;&gt;&lt;/ul&gt;',
  2239. filter: '&lt;li class=&quot;multiselect-item filter&quot;&gt;&lt;div class=&quot;input-group&quot;&gt;&lt;span class=&quot;input-group-addon&quot;&gt;&lt;i class=&quot;glyphicon glyphicon-search&quot;&gt;&lt;/i&gt;&lt;/span&gt;&lt;input class=&quot;form-control multiselect-search&quot; type=&quot;text&quot;&gt;&lt;/div&gt;&lt;/li&gt;',
  2240. filterClearBtn: '&lt;span class=&quot;input-group-btn&quot;&gt;&lt;button class=&quot;btn btn-default multiselect-clear-filter&quot; type=&quot;button&quot;&gt;&lt;i class=&quot;glyphicon glyphicon-remove-circle&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/span&gt;',
  2241. li: '&lt;li&gt;&lt;a href=&quot;javascript:void(0);&quot;&gt;&lt;label&gt;&lt;/label&gt;&lt;/a&gt;&lt;/li&gt;',
  2242. divider: '&lt;li class=&quot;multiselect-item divider&quot;&gt;&lt;/li&gt;',
  2243. liGroup: '&lt;li class=&quot;multiselect-item group&quot;&gt;&lt;label class=&quot;multiselect-group&quot;&gt;&lt;/label&gt;&lt;/li&gt;'
  2244. }
  2245. });
  2246. });
  2247. &lt;/script&gt;
  2248. </pre>
  2249. <p>
  2250. For example other elements instead of buttons may be used by adaptign the template:
  2251. </p>
  2252. <div class="example">
  2253. <script type="text/javascript">
  2254. $(document).ready(function() {
  2255. $('#example-templates-button').multiselect({
  2256. buttonContainer: '<div></div>',
  2257. buttonClass: '',
  2258. templates: {
  2259. button: '<span class="multiselect dropdown-toggle" data-toggle="dropdown">Click me!</span>'
  2260. }
  2261. });
  2262. });
  2263. </script>
  2264. <style type="text/css">
  2265. span.multiselect {
  2266. padding: 2px 6px;
  2267. font-weight: bold;
  2268. cursor: pointer;
  2269. }
  2270. </style>
  2271. <select id="example-templates-button" multiple="multiple">
  2272. <option value="1">Option 1</option>
  2273. <option value="2">Option 2</option>
  2274. <option value="3">Option 3</option>
  2275. <option value="4">Option 4</option>
  2276. <option value="5">Option 5</option>
  2277. <option value="6">Option 6</option>
  2278. </select>
  2279. </div>
  2280. <div class="highlight">
  2281. <pre class="prettyprint linenums">
  2282. &lt;script type=&quot;text/javascript&quot;&gt;
  2283. $(document).ready(function() {
  2284. $('#example-filter-placeholder').multiselect({
  2285. buttonContainer: '&lt;div&gt;&lt;/div&gt;',
  2286. buttonContainer: '',
  2287. buttonClass: '',
  2288. templates: {
  2289. button: '&lt;span class=&quot;multiselect dropdown-toggle&quot; data-toggle=&quot;dropdown&quot;&gt;Click me!&lt;/span&gt;'
  2290. }
  2291. });
  2292. });
  2293. &lt;/script&gt;
  2294. &lt;style type=&quot;text/css&quot;&gt;
  2295. span.multiselect {
  2296. padding: 2px 6px;
  2297. font-weight: bold;
  2298. cursor: pointer;
  2299. }
  2300. &lt;/style&gt;
  2301. </pre>
  2302. </div>
  2303. <div class="page-header">
  2304. <h2 id="methods">Methods</h2>
  2305. </div>
  2306. <table class="table">
  2307. <tbody>
  2308. <tr>
  2309. <td>
  2310. <code>.multiselect('destroy')</code>
  2311. </td>
  2312. <td>
  2313. <p>
  2314. This method is used to destroy the plugin on the given element - meaning unbinding the plugin.
  2315. </p>
  2316. <div class="example">
  2317. <div class="btn-group">
  2318. <script type="text/javascript">
  2319. $(document).ready(function() {
  2320. $('#example-destroy').multiselect();
  2321. $('#example-destroy-button').on('click', function() {
  2322. $('#example-destroy').multiselect('destroy');
  2323. });
  2324. });
  2325. </script>
  2326. <div class="btn-group">
  2327. <select id="example-destroy" multiple="multiple">
  2328. <option value="1">Option 1</option>
  2329. <option value="2">Option 2</option>
  2330. <option value="3">Option 3</option>
  2331. <option value="4">Option 4</option>
  2332. <option value="5">Option 5</option>
  2333. <option value="6">Option 6</option>
  2334. </select>
  2335. <button id="example-destroy-button" class="btn btn-danger">Destroy/Unbind</button>
  2336. </div>
  2337. </div>
  2338. </div>
  2339. <div class="highlight">
  2340. <pre class="prettyprint linenums">
  2341. &lt;script type=&quot;text/javascript&quot;&gt;
  2342. $(document).ready(function() {
  2343. $('#example-destroy').multiselect();
  2344. $('#example-destroy-button').on('click', function() {
  2345. $('#example-destroy').multiselect('destroy');
  2346. });
  2347. });
  2348. &lt;/script&gt;
  2349. </pre>
  2350. </div>
  2351. </td>
  2352. </tr>
  2353. <tr>
  2354. <td>
  2355. <code>.multiselect('refresh')</code>
  2356. </td>
  2357. <td>
  2358. <p>
  2359. This method is used to refresh the checked checkboxes based on the currently selected options within the <code>select</code>. Click &apos;Select some options&apos; to select some of the options. Then click refresh. The plugin will update the checkboxes accordingly.
  2360. </p>
  2361. <div class="example">
  2362. <div class="btn-group">
  2363. <script type="text/javascript">
  2364. $(document).ready(function() {
  2365. $('#example-refresh').multiselect();
  2366. $('#example-refresh-select').on('click', function() {
  2367. $('option[value="1"]', $('#example-refresh')).prop('selected', true);
  2368. $('option[value="3"]', $('#example-refresh')).prop('selected', true);
  2369. $('option[value="4"]', $('#example-refresh')).prop('selected', true);
  2370. alert('Option 1, 2 and 4.');
  2371. });
  2372. $('#example-refresh-deselect').on('click', function() {
  2373. $('option', $('#example-refresh')).each(function(element) {
  2374. $(this).removeAttr('selected').prop('selected', false);
  2375. });
  2376. });
  2377. $('#example-refresh-button').on('click', function() {
  2378. $('#example-refresh').multiselect('refresh');
  2379. });
  2380. });
  2381. </script>
  2382. <div class="btn-group">
  2383. <select id="example-refresh" multiple="multiple">
  2384. <option value="1">Option 1</option>
  2385. <option value="2">Option 2</option>
  2386. <option value="3">Option 3</option>
  2387. <option value="4">Option 4</option>
  2388. <option value="5">Option 5</option>
  2389. <option value="6">Option 6</option>
  2390. </select>
  2391. <button id="example-refresh-select" class="btn btn-default">Select some options!</button>
  2392. <button id="example-refresh-deselect" class="btn btn-default">Deselect some options...</button>
  2393. <button id="example-refresh-button" class="btn btn-primary">Refresh</button>
  2394. </div>
  2395. </div>
  2396. </div>
  2397. <div class="highlight">
  2398. <pre class="prettyprint linenums">
  2399. &lt;script type=&quot;text/javascript&quot;&gt;
  2400. $(document).ready(function() {
  2401. $('#example-refresh').multiselect();
  2402. $('#example-refresh-select').on('click', function() {
  2403. $('option[value="1"]', $('#example-refresh')).prop('selected', true);
  2404. $('option[value="3"]', $('#example-refresh')).prop('selected', true);
  2405. $('option[value="4"]', $('#example-refresh')).prop('selected', true);
  2406. alert('Option 1, 2 and 4.');
  2407. });
  2408. $('#example-refresh-deselect').on('click', function() {
  2409. $('option', $('#example-refresh')).each(function(element) {
  2410. $(this).removeAttr('selected').prop('selected', false);
  2411. });
  2412. });
  2413. $('#example-refresh-button').on('click', function() {
  2414. $('#example-refresh').multiselect('refresh');
  2415. });
  2416. });
  2417. &lt;/script&gt;
  2418. </pre>
  2419. </div>
  2420. </td>
  2421. </tr>
  2422. <tr>
  2423. <td>
  2424. <code>.multiselect('rebuild')</code>
  2425. </td>
  2426. <td>
  2427. <p>
  2428. Rebuilds the whole dropdown menu. All selected options will remain selected (if still existent!).
  2429. </p>
  2430. <div class="example">
  2431. <div class="btn-group">
  2432. <script type="text/javascript">
  2433. $(document).ready(function() {
  2434. $('#example-rebuild').multiselect();
  2435. $('#example-rebuild-button').on('click', function() {
  2436. $('#example-rebuild').multiselect('rebuild');
  2437. });
  2438. $('#example-rebuild-add').on('click', function() {
  2439. $('#example-rebuild').append('<option value="add1">Addition 1</option><option value="add2">Addition 2</option><option value="add3">Addition 3</option>');
  2440. });
  2441. $('#example-rebuild-delete').on('click', function() {
  2442. $('option[value="add1"]', $('#example-rebuild')).remove();
  2443. $('option[value="add2"]', $('#example-rebuild')).remove();
  2444. $('option[value="add3"]', $('#example-rebuild')).remove();
  2445. });
  2446. });
  2447. </script>
  2448. <div class="btn-group">
  2449. <select id="example-rebuild" multiple="multiple">
  2450. <option value="1">Option 1</option>
  2451. <option value="2">Option 2</option>
  2452. <option value="3">Option 3</option>
  2453. <option value="4">Option 4</option>
  2454. <option value="5">Option 5</option>
  2455. <option value="6">Option 6</option>
  2456. </select>
  2457. <button id="example-rebuild-add" class="btn btn-default">Add some options!</button>
  2458. <button id="example-rebuild-delete" class="btn btn-default">Remove some options...</button>
  2459. <button id="example-rebuild-button" class="btn btn-primary">Rebuild</button>
  2460. </div>
  2461. </div>
  2462. </div>
  2463. <div class="highlight">
  2464. <pre class="prettyprint linenums">
  2465. &lt;script type=&quot;text/javascript&quot;&gt;
  2466. $(document).ready(function() {
  2467. $('#example-rebuild').multiselect();
  2468. $('#example-rebuild-button').on('click', function() {
  2469. $('#example-rebuild').multiselect('rebuild');
  2470. });
  2471. $('#example-rebuild-add').on('click', function() {
  2472. $('#example-rebuild').append('&lt;option value="add1"&gt;Addition 1&lt;/option&gt;
  2473. &lt;option value="add2"&gt;Addition 2&lt;/option&gt;&lt;option value="add3"&gt;Addition 3&lt;/option&gt;');
  2474. });
  2475. $('#example-rebuild-delete').on('click', function() {
  2476. $('option[value="add1"]', $('#example-rebuild')).remove();
  2477. $('option[value="add2"]', $('#example-rebuild')).remove();
  2478. $('option[value="add3"]', $('#example-rebuild')).remove();
  2479. });
  2480. });
  2481. &lt;/script&gt;
  2482. </pre>
  2483. </div>
  2484. </td>
  2485. </tr>
  2486. <tr>
  2487. <td>
  2488. <code>.multiselect('select', value)</code>
  2489. </td>
  2490. <td>
  2491. <p>
  2492. Selects an option by its value. Works also using an array of values.
  2493. </p>
  2494. <div class="example">
  2495. <div class="btn-group">
  2496. <script type="text/javascript">
  2497. $(document).ready(function() {
  2498. $('#example-select').multiselect();
  2499. $('#example-select-button').on('click', function() {
  2500. $('#example-select').multiselect('select', ['1', '2', '4']);
  2501. alert('Selected 1, 2 and 4.');
  2502. });
  2503. });
  2504. </script>
  2505. <div class="btn-group">
  2506. <select id="example-select" multiple="multiple">
  2507. <option value="1">Option 1</option>
  2508. <option value="2">Option 2</option>
  2509. <option value="3">Option 3</option>
  2510. <option value="4">Option 4</option>
  2511. <option value="5">Option 5</option>
  2512. <option value="6">Option 6</option>
  2513. </select>
  2514. <button id="example-select-button" class="btn btn-default">Select some options...</button>
  2515. </div>
  2516. </div>
  2517. </div>
  2518. <div class="highlight">
  2519. <pre class="prettyprint linenums">
  2520. &lt;script type=&quot;text/javascript&quot;&gt;
  2521. $(document).ready(function() {
  2522. $('#example-select').multiselect();
  2523. $('#example-select-button').on('click', function() {
  2524. $('#example-select').multiselect('select', ['1', '2', '4']);
  2525. alert('Selected 1, 2 and 4.');
  2526. });
  2527. });
  2528. &lt;/script&gt;
  2529. </pre>
  2530. </div>
  2531. <p>
  2532. The method provides an additional parameter: <code>.multiselect('select', value, triggerOnChange)</code>. If the second parameter is set to true, the method will manually trigger the <code>onChange</code> option.
  2533. </p>
  2534. <div class="example">
  2535. <div class="btn-group">
  2536. <script type="text/javascript">
  2537. $(document).ready(function() {
  2538. $('#example-select-onChange').multiselect({
  2539. onChange: function(option, checked, select) {
  2540. alert('onChange triggered ...');
  2541. }
  2542. });
  2543. $('#example-select-onChange-button').on('click', function() {
  2544. $('#example-select-onChange').multiselect('select', '1', true);
  2545. });
  2546. });
  2547. </script>
  2548. <div class="btn-group">
  2549. <select id="example-select-onChange" multiple="multiple">
  2550. <option value="1">Option 1</option>
  2551. <option value="2">Option 2</option>
  2552. <option value="3">Option 3</option>
  2553. <option value="4">Option 4</option>
  2554. <option value="5">Option 5</option>
  2555. <option value="6">Option 6</option>
  2556. </select>
  2557. <button id="example-select-onChange-button" class="btn btn-default">Select one option</button>
  2558. </div>
  2559. </div>
  2560. </div>
  2561. <div class="highlight">
  2562. <pre class="prettyprint linenums">
  2563. &lt;script type=&quot;text/javascript&quot;&gt;
  2564. $(document).ready(function() {
  2565. $('#example-select-onChange').multiselect({
  2566. onChange: function(option, checked, select) {
  2567. alert('onChange triggered ...');
  2568. }
  2569. });
  2570. $('#example-select-onChange-button').on('click', function() {
  2571. $('#example-select-onChange').multiselect('select', '1', true);
  2572. });
  2573. });
  2574. &lt;/script&gt;
  2575. </pre>
  2576. </div>
  2577. <p>
  2578. The above parameter does also work when selecting multipe values. Note that <code>onChange</code> is called for each selected option individually!
  2579. </p>
  2580. <div class="example">
  2581. <div class="btn-group">
  2582. <script type="text/javascript">
  2583. $(document).ready(function() {
  2584. $('#example-select-onChange-array').multiselect({
  2585. onChange: function(option, checked, select) {
  2586. alert('onChange triggered ...');
  2587. }
  2588. });
  2589. $('#example-select-onChange-array-button').on('click', function() {
  2590. $('#example-select-onChange-array').multiselect('select', ['1', '3'], true);
  2591. });
  2592. });
  2593. </script>
  2594. <div class="btn-group">
  2595. <select id="example-select-onChange-array" multiple="multiple">
  2596. <option value="1">Option 1</option>
  2597. <option value="2">Option 2</option>
  2598. <option value="3">Option 3</option>
  2599. <option value="4">Option 4</option>
  2600. <option value="5">Option 5</option>
  2601. <option value="6">Option 6</option>
  2602. </select>
  2603. <button id="example-select-onChange-array-button" class="btn btn-default">Select two options</button>
  2604. </div>
  2605. </div>
  2606. </div>
  2607. <div class="highlight">
  2608. <pre class="prettyprint linenums">
  2609. &lt;script type=&quot;text/javascript&quot;&gt;
  2610. $(document).ready(function() {
  2611. $('#example-select-onChange-array').multiselect({
  2612. onChange: function(option, checked, select) {
  2613. alert('onChange triggered ...');
  2614. }
  2615. });
  2616. $('#example-select-onChange-button').on('click', function() {
  2617. $('#example-select-onChange').multiselect('select', '1', true);
  2618. });
  2619. });
  2620. &lt;/script&gt;
  2621. </pre>
  2622. </div>
  2623. </td>
  2624. </tr>
  2625. <tr>
  2626. <td>
  2627. <code>.multiselect('deselect', value)</code>
  2628. </td>
  2629. <td>
  2630. <p>
  2631. Deselect an option by its value. Works also using an array of values.
  2632. </p>
  2633. <div class="example">
  2634. <div class="btn-group">
  2635. <script type="text/javascript">
  2636. $(document).ready(function() {
  2637. $('#example-deselect').multiselect();
  2638. $('#example-deselect-button').on('click', function() {
  2639. $('#example-deselect').multiselect('deselect', ['1', '2', '4']);
  2640. alert('Deselected 1, 2 and 4.');
  2641. });
  2642. });
  2643. </script>
  2644. <div class="btn-group">
  2645. <select id="example-deselect" multiple="multiple">
  2646. <option value="1">Option 1</option>
  2647. <option value="2">Option 2</option>
  2648. <option value="3">Option 3</option>
  2649. <option value="4">Option 4</option>
  2650. <option value="5">Option 5</option>
  2651. <option value="6">Option 6</option>
  2652. </select>
  2653. <button id="example-deselect-button" class="btn btn-default">Deselect some options...</button>
  2654. </div>
  2655. </div>
  2656. </div>
  2657. <div class="highlight">
  2658. <pre class="prettyprint linenums">
  2659. &lt;script type=&quot;text/javascript&quot;&gt;
  2660. $(document).ready(function() {
  2661. $('#example-deselect').multiselect();
  2662. $('#example-deselect-button').on('click', function() {
  2663. $('#example-deselect').multiselect('deselect', ['1', '2', '4']);
  2664. alert('Deselected 1, 2 and 4.');
  2665. });
  2666. });
  2667. &lt;/script&gt;
  2668. </pre>
  2669. </div>
  2670. <p>
  2671. The method provides an additional parameter: <code>.multiselect('deselect', value, triggerOnChange)</code>. If the second parameter is set to true, the method will manually trigger the <code>onChange</code> option.
  2672. </p>
  2673. <div class="example">
  2674. <div class="btn-group">
  2675. <script type="text/javascript">
  2676. $(document).ready(function() {
  2677. $('#example-deselect-onChange').multiselect({
  2678. onChange: function(option, checked, select) {
  2679. alert('onChange triggered ...');
  2680. }
  2681. });
  2682. $('#example-deselect-onChange-button').on('click', function() {
  2683. $('#example-deselect-onChange').multiselect('deselect', '1', true);
  2684. });
  2685. });
  2686. </script>
  2687. <div class="btn-group">
  2688. <select id="example-deselect-onChange" multiple="multiple">
  2689. <option value="1">Option 1</option>
  2690. <option value="2">Option 2</option>
  2691. <option value="3">Option 3</option>
  2692. <option value="4">Option 4</option>
  2693. <option value="5">Option 5</option>
  2694. <option value="6">Option 6</option>
  2695. </select>
  2696. <button id="example-deselect-onChange-button" class="btn btn-default">Deselect one option</button>
  2697. </div>
  2698. </div>
  2699. </div>
  2700. <div class="highlight">
  2701. <pre class="prettyprint linenums">
  2702. &lt;script type=&quot;text/javascript&quot;&gt;
  2703. $(document).ready(function() {
  2704. $('#example-deselect-onChange').multiselect({
  2705. onChange: function(option, checked, select) {
  2706. alert('onChange triggered ...');
  2707. }
  2708. });
  2709. $('#example-deselect-onChange-button').on('click', function() {
  2710. $('#example-deselect-onChange').multiselect('deselect', '1', true);
  2711. });
  2712. });
  2713. &lt;/script&gt;
  2714. </pre>
  2715. </div>
  2716. <p>
  2717. The above parameter does also work when deselecting multiple options. Note that <code>onChange</code> is called for each deselected option individually.
  2718. </p>
  2719. <div class="example">
  2720. <div class="btn-group">
  2721. <script type="text/javascript">
  2722. $(document).ready(function() {
  2723. $('#example-deselect-onChange-array').multiselect({
  2724. onChange: function(option, checked, select) {
  2725. alert('onChange triggered ...');
  2726. }
  2727. });
  2728. $('#example-deselect-onChange-array-button').on('click', function() {
  2729. $('#example-deselect-onChange-array').multiselect('deselect', ['1', '3'], true);
  2730. });
  2731. });
  2732. </script>
  2733. <div class="btn-group">
  2734. <select id="example-deselect-onChange-array" multiple="multiple">
  2735. <option value="1" selected>Option 1</option>
  2736. <option value="2">Option 2</option>
  2737. <option value="3" selected>Option 3</option>
  2738. <option value="4">Option 4</option>
  2739. <option value="5">Option 5</option>
  2740. <option value="6">Option 6</option>
  2741. </select>
  2742. <button id="example-deselect-onChange-array-button" class="btn btn-default">Deselect two options</button>
  2743. </div>
  2744. </div>
  2745. </div>
  2746. <div class="highlight">
  2747. <pre class="prettyprint linenums">
  2748. &lt;script type=&quot;text/javascript&quot;&gt;
  2749. $(document).ready(function() {
  2750. $('#example-deselect-onChange-array').multiselect({
  2751. onChange: function(option, checked, select) {
  2752. alert('onChange triggered ...');
  2753. }
  2754. });
  2755. $('#example-deselect-onChange-array-button').on('click', function() {
  2756. $('#example-deselect-onChange-array').multiselect('deselect', '1', true);
  2757. });
  2758. });
  2759. &lt;/script&gt;
  2760. </pre>
  2761. </div>
  2762. </td>
  2763. </tr>
  2764. <tr>
  2765. <td>
  2766. <code>.multiselect('selectAll', justVisible)</code>
  2767. </td>
  2768. <td>
  2769. <p>
  2770. Selects all options. If <code>justVisible</code> is set to <code>true</code> or not provided, all visible options are selected (when using the filter), otherweise (<code>justVisible</code> set to <code>false</code>) all options are selected.
  2771. </p>
  2772. <p class="alert alert-info">
  2773. Note that setting <code>justVisible</code> to <code>true</code>, or providing no parameter will select all visible options, that is the dropdown needs to be opened.
  2774. </p>
  2775. <p class="alert alert-info">
  2776. Currently, it is required to call <code>.multiselect('updateButtonText')</code> manually after calling <code>.multiselect('selectAll', justVisible)</code>.
  2777. </p>
  2778. <div class="example">
  2779. <div class="btn-group">
  2780. <script type="text/javascript">
  2781. $(document).ready(function() {
  2782. $('#example-selectAll').multiselect();
  2783. $('#example-selectAll-visible').on('click', function() {
  2784. $('#example-selectAll').multiselect('selectAll', true);
  2785. $('#example-selectAll').multiselect('updateButtonText');
  2786. });
  2787. $('#example-selectAll-all').on('click', function() {
  2788. $('#example-selectAll').multiselect('selectAll', false);
  2789. $('#example-selectAll').multiselect('updateButtonText');
  2790. });
  2791. });
  2792. </script>
  2793. <div class="btn-group">
  2794. <select id="example-selectAll" multiple="multiple">
  2795. <option value="1">Option 1</option>
  2796. <option value="2">Option 2</option>
  2797. <option value="3">Option 3</option>
  2798. <option value="4">Option 4</option>
  2799. <option value="5">Option 5</option>
  2800. <option value="6">Option 6</option>
  2801. </select>
  2802. <button id="example-selectAll-visible" class="btn btn-default">Select all visible options</button>
  2803. <button id="example-selectAll-all" class="btn btn-default">Select all options</button>
  2804. </div>
  2805. </div>
  2806. </div>
  2807. <div class="highlight">
  2808. <pre class="prettyprint linenums">
  2809. &lt;script type=&quot;text/javascript&quot;&gt;
  2810. $(document).ready(function() {
  2811. $('#example-selectAll').multiselect();
  2812. $('#example-selectAll-visible').on('click', function() {
  2813. $('#example-selectAll').multiselect('selectAll', true);
  2814. $('#example-selectAll').multiselect('updateButtonText');
  2815. });
  2816. $('#example-selectAll-all').on('click', function() {
  2817. $('#example-selectAll').multiselect('selectAll', false);
  2818. $('#example-selectAll').multiselect('updateButtonText');
  2819. });
  2820. });
  2821. &lt;/script&gt;
  2822. </pre>
  2823. </div>
  2824. </td>
  2825. </tr>
  2826. <tr>
  2827. <td>
  2828. <code>.multiselect('deselectAll', justVisible)</code>
  2829. </td>
  2830. <td>
  2831. <p>
  2832. Deselects all options. If <code>justVisible</code> is set to <code>true</code> or not provided, all visible options are deselected, otherweise (<code>justVisible</code> set to <code>false</code>) all options are deselected.
  2833. </p>
  2834. <p class="alert alert-info">
  2835. Note that setting <code>justVisible</code> to <code>true</code>, or providing no parameter will select all visible options, that is the dropdown needs to be opened.
  2836. </p>
  2837. <p class="alert alert-info">
  2838. Currently, it is required to call <code>.multiselect('updateButtonText')</code> manually after calling <code>.multiselect('selectAll', justVisible)</code>.
  2839. </p>
  2840. <div class="example">
  2841. <div class="btn-group">
  2842. <script type="text/javascript">
  2843. $(document).ready(function() {
  2844. $('#example-deselectAll').multiselect();
  2845. $('#example-deselectAll-visible').on('click', function() {
  2846. $('#example-deselectAll').multiselect('deselectAll', true);
  2847. $('#example-deselectAll').multiselect('updateButtonText');
  2848. });
  2849. $('#example-deselectAll-all').on('click', function() {
  2850. $('#example-deselectAll').multiselect('deselectAll', false);
  2851. $('#example-deselectAll').multiselect('updateButtonText');
  2852. });
  2853. });
  2854. </script>
  2855. <div class="btn-group">
  2856. <select id="example-deselectAll" multiple="multiple">
  2857. <option value="1">Option 1</option>
  2858. <option value="2">Option 2</option>
  2859. <option value="3">Option 3</option>
  2860. <option value="4">Option 4</option>
  2861. <option value="5">Option 5</option>
  2862. <option value="6">Option 6</option>
  2863. </select>
  2864. <button id="example-deselectAll-visible" class="btn btn-default">Deselect all visible options</button>
  2865. <button id="example-deselectAll-all" class="btn btn-default">Deselect all options</button>
  2866. </div>
  2867. </div>
  2868. </div>
  2869. <div class="highlight">
  2870. <pre class="prettyprint linenums">
  2871. &lt;script type=&quot;text/javascript&quot;&gt;
  2872. $(document).ready(function() {
  2873. $('#example-deselectAll').multiselect();
  2874. $('#example-deselectAll-visible').on('click', function() {
  2875. $('#example-deselectAll').multiselect('deselectAll', true);
  2876. $('#example-deselectAll').multiselect('updateButtonText');
  2877. });
  2878. $('#example-deselectAll-all').on('click', function() {
  2879. $('#example-deselectAll').multiselect('deselectAll', false);
  2880. $('#example-deselectAll').multiselect('updateButtonText');
  2881. });
  2882. });
  2883. &lt;/script&gt;
  2884. </pre>
  2885. </div>
  2886. </td>
  2887. </tr>
  2888. <tr>
  2889. <td>
  2890. <code>.multiselect('updateButtonText')</code>
  2891. </td>
  2892. <td>
  2893. <p>
  2894. When manually selecting/deselecting options and the corresponding checkboxes, this function updates the text and title of the button.
  2895. </p>
  2896. <p class="alert alert-info">
  2897. Note that usually this method is only needed when using <code>.multiselect('selectAll', justVisible)</code> or <code>.multiselect('deselectAll', justVisible)</code>. In all other cases, <code>.multiselect('refresh')</code> should be used.
  2898. </p>
  2899. <div class="example">
  2900. <div class="btn-group">
  2901. <script type="text/javascript">
  2902. $(document).ready(function() {
  2903. $('#example-updateButtonText').multiselect({
  2904. buttonContainer: '<div class="btn-group" id="example-updateButtonText-container"></div>'
  2905. });
  2906. $('#example-updateButtonText-select').on('click', function() {
  2907. $('option[value="1"]', $('#example-updateButtonText')).prop('selected', true);
  2908. $('option[value="3"]', $('#example-updateButtonText')).prop('selected', true);
  2909. $('input[value="1"]', $('#example-updateButtonText-container')).prop('checked', true);
  2910. $('input[value="3"]', $('#example-updateButtonText-container')).prop('checked', true);
  2911. $('input[value="1"]', $('#example-updateButtonText-container')).closest('li').addClass('active');
  2912. $('input[value="3"]', $('#example-updateButtonText-container')).closest('li').addClass('active');
  2913. });
  2914. $('#example-updateButtonText-update').on('click', function() {
  2915. $('#example-updateButtonText').multiselect('updateButtonText');
  2916. });
  2917. });
  2918. </script>
  2919. <div class="btn-group">
  2920. <select id="example-updateButtonText" multiple="multiple">
  2921. <option value="1">Option 1</option>
  2922. <option value="2">Option 2</option>
  2923. <option value="3">Option 3</option>
  2924. <option value="4">Option 4</option>
  2925. <option value="5">Option 5</option>
  2926. <option value="6">Option 6</option>
  2927. </select>
  2928. <button id="example-updateButtonText-select" class="btn btn-default">Select some options ...</button>
  2929. <button id="example-updateButtonText-update" class="btn btn-default">Update</button>
  2930. </div>
  2931. </div>
  2932. </div>
  2933. <div class="highlight">
  2934. <pre class="prettyprint linenums">
  2935. &lt;script type=&quot;text/javascript&quot;&gt;
  2936. $(document).ready(function() {
  2937. $('#example-deselectAll').multiselect();
  2938. $('#example-deselectAll-visible').on('click', function() {
  2939. $('#example-deselectAll').multiselect('updateButtonText', true);
  2940. });
  2941. });
  2942. &lt;/script&gt;
  2943. </pre>
  2944. </div>
  2945. </td>
  2946. </tr>
  2947. <tr>
  2948. <td>
  2949. <code>.multiselect('setOptions', options)</code>
  2950. </td>
  2951. <td>
  2952. <p>
  2953. Used to change configuration after initializing the multiselect. This may be useful in combination with <code>.multiselect('rebuild')</code>.
  2954. </p>
  2955. <div class="example">
  2956. <script type="text/javascript">
  2957. $(document).ready(function() {
  2958. var firstConfigurationSet = {
  2959. includeSelectAllOption: false,
  2960. enableFiltering: false
  2961. };
  2962. var secondConfigurationSet = {
  2963. includeSelectAllOption: false,
  2964. enableFiltering: true
  2965. };
  2966. var set = 1;
  2967. $('#example-setOptions').multiselect(firstConfigurationSet);
  2968. function rebuildMultiselect(options) {
  2969. $('#example-setOptions').multiselect('setOptions', options);
  2970. $('#example-setOptions').multiselect('rebuild');
  2971. }
  2972. $('#example-setOptions-button').on('click', function(event) {
  2973. switch (set) {
  2974. case 2:
  2975. rebuildMultiselect(firstConfigurationSet);
  2976. $(this).text('Configuration Set 2');
  2977. set = 1;
  2978. break;
  2979. case 1:
  2980. default:
  2981. rebuildMultiselect(secondConfigurationSet);
  2982. $(this).text('Configuration Set 1');
  2983. set = 2;
  2984. break;
  2985. }
  2986. });
  2987. });
  2988. </script>
  2989. <div class="btn-group">
  2990. <select id="example-setOptions" multiple="multiple">
  2991. <option value="1">Option 1</option>
  2992. <option value="2">Option 2</option>
  2993. <option value="3">Option 3</option>
  2994. <option value="4">Option 4</option>
  2995. <option value="5">Option 5</option>
  2996. <option value="6">Option 6</option>
  2997. </select>
  2998. <button id="example-setOptions-button" class="btn btn-primary">Configuration Set 2</button>
  2999. </div>
  3000. </div>
  3001. <div class="highlight">
  3002. <pre class="prettyprint linenums">
  3003. &lt;script type=&quot;text/javascript&quot;&gt;
  3004. $(document).ready(function() {
  3005. var firstConfigurationSet = {
  3006. includeSelectAllOption: false,
  3007. enableFiltering: false
  3008. };
  3009. var secondConfigurationSet = {
  3010. includeSelectAllOption: false,
  3011. enableFiltering: true
  3012. };
  3013. var set = 1;
  3014. $('#example-setOptions').multiselect(firstConfigurationSet);
  3015. function rebuildMultiselect(options) {
  3016. $('#example-setOptions').multiselect('setOptions', options);
  3017. $('#example-setOptions').multiselect('rebuild');
  3018. }
  3019. $('#example-setOptions-button').on('click', function(event) {
  3020. switch (set) {
  3021. case 2:
  3022. rebuildMultiselect(firstConfigurationSet);
  3023. $(this).text('Configuration Set 2');
  3024. set = 1;
  3025. break;
  3026. case 1:
  3027. default:
  3028. rebuildMultiselect(secondConfigurationSet);
  3029. $(this).text('Configuration Set 1');
  3030. set = 2;
  3031. break;
  3032. }
  3033. });
  3034. });
  3035. &lt;/script&gt;
  3036. </pre>
  3037. </div>
  3038. </td>
  3039. </tr>
  3040. <tr>
  3041. <td>
  3042. <code>.multiselect('disable')</code>
  3043. </td>
  3044. <td>
  3045. <p>
  3046. Disable both the underlying select and the dropdown button.
  3047. </p>
  3048. <div class="example">
  3049. <div class="btn-group">
  3050. <script type="text/javascript">
  3051. $(document).ready(function() {
  3052. $('#example-disable').multiselect();
  3053. $('#example-disable-button').on('click', function() {
  3054. $('#example-disable').multiselect('disable');
  3055. });
  3056. });
  3057. </script>
  3058. <div class="btn-group">
  3059. <select id="example-disable" multiple="multiple">
  3060. <option value="1">Option 1</option>
  3061. <option value="2">Option 2</option>
  3062. <option value="3">Option 3</option>
  3063. <option value="4">Option 4</option>
  3064. <option value="5">Option 5</option>
  3065. <option value="6">Option 6</option>
  3066. </select>
  3067. <button id="example-disable-button" class="btn btn-primary">Disable...</button>
  3068. </div>
  3069. </div>
  3070. </div>
  3071. <div class="highlight">
  3072. <pre class="prettyprint linenums">
  3073. &lt;script type=&quot;text/javascript&quot;&gt;
  3074. $(document).ready(function() {
  3075. $('#example-disable').multiselect();
  3076. $('#example-disable-button').on('click', function() {
  3077. $('#example-disable').multiselect('disable');
  3078. });
  3079. });
  3080. &lt;/script&gt;
  3081. </pre>
  3082. </div>
  3083. </td>
  3084. </tr>
  3085. <tr>
  3086. <td>
  3087. <code>.multiselect('enable')</code>
  3088. </td>
  3089. <td>
  3090. <p>
  3091. Enable both the underlying select and the dropdown button.
  3092. </p>
  3093. <div class="example">
  3094. <div class="btn-group">
  3095. <script type="text/javascript">
  3096. $(document).ready(function() {
  3097. $('#example-enable').multiselect();
  3098. $('#example-enable-button').on('click', function() {
  3099. $('#example-enable').multiselect('enable');
  3100. });
  3101. });
  3102. </script>
  3103. <div class="btn-group">
  3104. <select id="example-enable" disabled="disabled" multiple="multiple">
  3105. <option value="1">Option 1</option>
  3106. <option value="2">Option 2</option>
  3107. <option value="3">Option 3</option>
  3108. <option value="4">Option 4</option>
  3109. <option value="5">Option 5</option>
  3110. <option value="6">Option 6</option>
  3111. </select>
  3112. <button id="example-enable-button" class="btn btn-default">Enable!</button>
  3113. </div>
  3114. </div>
  3115. </div>
  3116. <div class="highlight">
  3117. <pre class="prettyprint linenums">
  3118. &lt;script type=&quot;text/javascript&quot;&gt;
  3119. $(document).ready(function() {
  3120. $('#example-enable').multiselect();
  3121. $('#example-enable-button').on('click', function() {
  3122. $('#example-enable').multiselect('enable');
  3123. });
  3124. });
  3125. &lt;/script&gt;
  3126. </pre>
  3127. </div>
  3128. </td>
  3129. </tr>
  3130. <tr>
  3131. <td>
  3132. <code>.multiselect('dataprovider', data)</code>
  3133. </td>
  3134. <td>
  3135. <p>
  3136. This method is used to provide options programmatically. See the example below.
  3137. </p>
  3138. <div class="example">
  3139. <div class="btn-group">
  3140. <script type="text/javascript">
  3141. $(document).ready(function() {
  3142. $('#example-dataprovider').multiselect();
  3143. var options = [
  3144. {label: 'Option 1', title: 'Option 1', value: '1', selected: true},
  3145. {label: 'Option 2', title: 'Option 2', value: '2'},
  3146. {label: 'Option 3', title: 'Option 3', value: '3', selected: true},
  3147. {label: 'Option 4', title: 'Option 4', value: '4'},
  3148. {label: 'Option 5', title: 'Option 5', value: '5'},
  3149. {label: 'Option 6', title: 'Option 6', value: '6', disabled: true}
  3150. ];
  3151. $('#example-dataprovider').multiselect('dataprovider', options);
  3152. });
  3153. </script>
  3154. <select id="example-dataprovider" multiple="multiple"></select>
  3155. </div>
  3156. </div>
  3157. <div class="highlight">
  3158. <pre class="prettyprint linenums">
  3159. &lt;script type=&quot;text/javascript&quot;&gt;
  3160. $('#example-dataprovider').multiselect();
  3161. var options = [
  3162. {label: 'Option 1', title: 'Option 1', value: '1', selected: true},
  3163. {label: 'Option 2', title: 'Option 2', value: '2'},
  3164. {label: 'Option 3', title: 'Option 3', value: '3', selected: true},
  3165. {label: 'Option 4', title: 'Option 4', value: '4'},
  3166. {label: 'Option 5', title: 'Option 5', value: '5'},
  3167. {label: 'Option 6', title: 'Option 6', value: '6', disabled: true}
  3168. ];
  3169. $('#example-dataprovider').multiselect('dataprovider', options);
  3170. &lt;/script&gt;
  3171. &lt;select id=&quot;example-dataprovider&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt;
  3172. </pre>
  3173. </div>
  3174. <p>
  3175. The method is also able to handle <code>optgroup</code>'s:
  3176. </p>
  3177. <div class="example">
  3178. <div class="btn-group">
  3179. <script type="text/javascript">
  3180. $(document).ready(function() {
  3181. $('#example-dataprovider-optgroups').multiselect();
  3182. var optgroups = [
  3183. {
  3184. label: 'Group 1', children: [
  3185. {label: 'Option 1.1', value: '1-1', selected: true},
  3186. {label: 'Option 1.2', value: '1-2'},
  3187. {label: 'Option 1.3', value: '1-3'}
  3188. ]
  3189. },
  3190. {
  3191. label: 'Group 2', children: [
  3192. {label: 'Option 2.1', value: '1'},
  3193. {label: 'Option 2.2', value: '2'},
  3194. {label: 'Option 2.3', value: '3', disabled: true}
  3195. ]
  3196. }
  3197. ];
  3198. $('#example-dataprovider-optgroups').multiselect('dataprovider', optgroups);
  3199. });
  3200. </script>
  3201. <select id="example-dataprovider-optgroups" multiple="multiple"></select>
  3202. </div>
  3203. </div>
  3204. <div class="highlight">
  3205. <pre class="prettyprint linenums">
  3206. &lt;script type=&quot;text/javascript&quot;&gt;
  3207. $('#example-dataprovider-optgroups').multiselect();
  3208. var optgroups = [
  3209. {
  3210. label: 'Group 1', children: [
  3211. {label: 'Option 1.1', value: '1-1', selected: true},
  3212. {label: 'Option 1.2', value: '1-2'},
  3213. {label: 'Option 1.3', value: '1-3'}
  3214. ]
  3215. },
  3216. {
  3217. label: 'Group 2', children: [
  3218. {label: 'Option 2.1', value: '1'},
  3219. {label: 'Option 2.2', value: '2'},
  3220. {label: 'Option 2.3', value: '3', disabled: true}
  3221. ]
  3222. }
  3223. ];
  3224. $('#example-dataprovider-optgroups').multiselect('dataprovider', optgroups);
  3225. &lt;/script&gt;
  3226. &lt;select id=&quot;example-dataprovider-optgroups&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt;
  3227. </pre>
  3228. </div>
  3229. </td>
  3230. </tr>
  3231. <tr>
  3232. <td>
  3233. <code>.multiselect('setAllSelectedText', value)</code>
  3234. </td>
  3235. <td>
  3236. <p>
  3237. This method is used to programmatically provide a new text to display in the button when all options are selected, at runtime.
  3238. </p>
  3239. <div class="example">
  3240. <div class="btn-group">
  3241. <script type="text/javascript">
  3242. $(document).ready(function() {
  3243. $('#example-set-all-selected-text').multiselect({allSelectedText: "Initial All Selected"});
  3244. $('#new-all-selected-text-btn').click(function(){
  3245. $('#example-set-all-selected-text').multiselect('setAllSelectedText', $('#new-all-selected-text-box').val());
  3246. });
  3247. });
  3248. </script>
  3249. <select id="example-set-all-selected-text" multiple="multiple">
  3250. <option value="1" selected>Option 1</option>
  3251. </select>
  3252. <input id="new-all-selected-text-box" type="text" class="form-control" placeholder="Enter new text"/>
  3253. <input id="new-all-selected-text-btn" type="button" class="btn btn-default" value="Change All Selected Text"/>
  3254. </div>
  3255. </div>
  3256. <div class="highlight">
  3257. <pre class="prettyprint linenums">
  3258. &lt;script type=&quot;text/javascript&quot;&gt;
  3259. $('#example-set-all-selected-text').multiselect({allSelectedText: "Initial All Selected"});
  3260. $('#new-all-selected-text-btn').click(function(){
  3261. $('#example-set-all-selected-text').multiselect('setAllSelectedText', $('#new-all-selected-text-box').val());
  3262. });
  3263. &lt;/script&gt;
  3264. </pre>
  3265. </div>
  3266. </td>
  3267. </tr>
  3268. </tbody>
  3269. </table>
  3270. <div class="page-header">
  3271. <h2 id="further-examples">Further Examples</h2>
  3272. </div>
  3273. <p>
  3274. Using the <code>onChange</code> configuration option, the following example asks for confirmation if deselecting an option.
  3275. </p>
  3276. <div class="example">
  3277. <script type="text/javascript">
  3278. $(document).ready(function() {
  3279. $('#example-confirmation').multiselect({
  3280. onChange: function(element, checked) {
  3281. if(checked === true) {
  3282. //action taken here if true
  3283. }
  3284. else if(checked === false) {
  3285. if(confirm('Do you wish to deselect the element?')) {
  3286. //action taken here
  3287. }
  3288. else {
  3289. $("#example-confirmation").multiselect('select', element.val());
  3290. }
  3291. }
  3292. }
  3293. });
  3294. });
  3295. </script>
  3296. <select id="example-confirmation" multiple="multiple">
  3297. <option value="1">Option 1</option>
  3298. <option value="2">Option 2</option>
  3299. <option value="3">Option 3</option>
  3300. <option value="4">Option 4</option>
  3301. <option value="5">Option 5</option>
  3302. <option value="6">Option 6</option>
  3303. </select>
  3304. </div>
  3305. <div class="highlight">
  3306. <pre class="prettyprint linenums">
  3307. &lt;script type=&quot;text/javascript&quot;&gt;
  3308. $(document).ready(function() {
  3309. $('#example-confirmation').multiselect({
  3310. onChange: function(element, checked) {
  3311. if(checked === true) {
  3312. //action taken here if true
  3313. }
  3314. else if(checked === false) {
  3315. if(confirm('Do you wish to deselect the element?')) {
  3316. //action taken here
  3317. }
  3318. else {
  3319. $("#example-confirmation").multiselect('select', element.val());
  3320. }
  3321. }
  3322. }
  3323. });
  3324. });
  3325. &lt;/script&gt;
  3326. </pre>
  3327. </div>
  3328. <p>
  3329. Limit the number of selected options using the <code>onChange</code> option. The user may only select a maximum of 4 options. Then all other options are disabled.
  3330. </p>
  3331. <div class="example">
  3332. <script type="text/javascript">
  3333. $(document).ready(function() {
  3334. $('#example-limit').multiselect({
  3335. onChange: function(option, checked) {
  3336. // Get selected options.
  3337. var selectedOptions = $('#example-limit option:selected');
  3338. if (selectedOptions.length >= 4) {
  3339. // Disable all other checkboxes.
  3340. var nonSelectedOptions = $('#example-limit option').filter(function() {
  3341. return !$(this).is(':selected');
  3342. });
  3343. var dropdown = $('#example-limit').siblings('.multiselect-container');
  3344. nonSelectedOptions.each(function() {
  3345. var input = $('input[value="' + $(this).val() + '"]');
  3346. input.prop('disabled', true);
  3347. input.parent('li').addClass('disabled');
  3348. });
  3349. }
  3350. else {
  3351. // Enable all checkboxes.
  3352. var dropdown = $('#example-limit').siblings('.multiselect-container');
  3353. $('#example-limit option').each(function() {
  3354. var input = $('input[value="' + $(this).val() + '"]');
  3355. input.prop('disabled', false);
  3356. input.parent('li').addClass('disabled');
  3357. });
  3358. }
  3359. }
  3360. });
  3361. });
  3362. </script>
  3363. <select id="example-limit" multiple="multiple">
  3364. <option value="1">Option 1</option>
  3365. <option value="2">Option 2</option>
  3366. <option value="3">Option 3</option>
  3367. <option value="4">Option 4</option>
  3368. <option value="5">Option 5</option>
  3369. <option value="6">Option 6</option>
  3370. </select>
  3371. </div>
  3372. <div class="highlight">
  3373. <pre class="prettyprint linenums">
  3374. &lt;script type=&quot;text/javascript&quot;&gt;
  3375. $(document).ready(function() {
  3376. $('#example-limit').multiselect({
  3377. onChange: function(option, checked) {
  3378. // Get selected options.
  3379. var selectedOptions = $('#example-limit option:selected');
  3380. if (selectedOptions.length >= 4) {
  3381. // Disable all other checkboxes.
  3382. var nonSelectedOptions = $('#example-limit option').filter(function() {
  3383. return !$(this).is(':selected');
  3384. });
  3385. var dropdown = $('#example-limit').siblings('.multiselect-container');
  3386. nonSelectedOptions.each(function() {
  3387. var input = $('input[value="' + $(this).val() + '"]');
  3388. input.prop('disabled', true);
  3389. input.parent('li').addClass('disabled');
  3390. });
  3391. }
  3392. else {
  3393. // Enable all checkboxes.
  3394. var dropdown = $('#example-limit').siblings('.multiselect-container');
  3395. $('#example-limit option').each(function() {
  3396. var input = $('input[value="' + $(this).val() + '"]');
  3397. input.prop('disabled', false);
  3398. input.parent('li').addClass('disabled');
  3399. });
  3400. }
  3401. }
  3402. });
  3403. });
  3404. &lt;/script&gt;
  3405. </pre>
  3406. </div>
  3407. <p>
  3408. Record the order the options are selected. When selecting an item an ordering number will be incremented and saved within the option.
  3409. </p>
  3410. <div class="example">
  3411. <script type="text/javascript">
  3412. $(document).ready(function() {
  3413. var orderCount = 0;
  3414. $('#example-order').multiselect({
  3415. onChange: function(option, checked) {
  3416. if (checked) {
  3417. orderCount++;
  3418. $(option).data('order', orderCount);
  3419. }
  3420. else {
  3421. $(option).data('order', '');
  3422. }
  3423. },
  3424. buttonText: function(options) {
  3425. if (options.length === 0) {
  3426. return 'None selected';
  3427. }
  3428. else if (options.length > 3) {
  3429. return options.length + ' selected';
  3430. }
  3431. else {
  3432. var selected = [];
  3433. options.each(function() {
  3434. selected.push([$(this).text(), $(this).data('order')]);
  3435. });
  3436. selected.sort(function(a, b) {
  3437. return a[1] - b[1];
  3438. });
  3439. var text = '';
  3440. for (var i = 0; i < selected.length; i++) {
  3441. text += selected[i][0] + ', ';
  3442. }
  3443. return text.substr(0, text.length -2);
  3444. }
  3445. }
  3446. });
  3447. $('#example-order-button').on('click', function() {
  3448. var selected = [];
  3449. $('#example-order option:selected').each(function() {
  3450. selected.push([$(this).val(), $(this).data('order')]);
  3451. });
  3452. selected.sort(function(a, b) {
  3453. return a[1] - b[1];
  3454. });
  3455. var text = '';
  3456. for (var i = 0; i < selected.length; i++) {
  3457. text += selected[i][0] + ', ';
  3458. }
  3459. text = text.substring(0, text.length - 2);
  3460. alert(text);
  3461. });
  3462. });
  3463. </script>
  3464. <div class="btn-group">
  3465. <select id="example-order" multiple="multiple">
  3466. <option value="1">Option 1</option>
  3467. <option value="2">Option 2</option>
  3468. <option value="3">Option 3</option>
  3469. <option value="4">Option 4</option>
  3470. <option value="5">Option 5</option>
  3471. <option value="6">Option 6</option>
  3472. </select>
  3473. <button id="example-order-button" class="btn btn-primary">Order</button>
  3474. </div>
  3475. </div>
  3476. <div class="highlight">
  3477. <pre class="prettyprint linenums">
  3478. &lt;script type=&quot;text/javascript&quot;&gt;
  3479. $(document).ready(function() {
  3480. var orderCount = 0;
  3481. $('#example-order').multiselect({
  3482. onChange: function(option, checked) {
  3483. if (checked) {
  3484. orderCount++;
  3485. $(option).data('order', orderCount);
  3486. }
  3487. else {
  3488. $(option).data('order', '');
  3489. }
  3490. },
  3491. buttonText: function(options) {
  3492. if (options.length === 0) {
  3493. return 'None selected';
  3494. }
  3495. else if (options.length > 3) {
  3496. return options.length + ' selected';
  3497. }
  3498. else {
  3499. var selected = [];
  3500. options.each(function() {
  3501. selected.push([$(this).text(), $(this).data('order')]);
  3502. });
  3503. selected.sort(function(a, b) {
  3504. return a[1] - b[1];
  3505. });
  3506. var text = '';
  3507. for (var i = 0; i < selected.length; i++) {
  3508. text += selected[i][0] + ', ';
  3509. }
  3510. return text.substr(0, text.length -2);
  3511. }
  3512. },
  3513. });
  3514. $('#example-order-button').on('click', function() {
  3515. var selected = [];
  3516. $('#example-order option:selected').each(function() {
  3517. selected.push([$(this).val(), $(this).data('order')]);
  3518. });
  3519. selected.sort(function(a, b) {
  3520. return a[1] - b[1];
  3521. });
  3522. var text = '';
  3523. for (var i = 0; i < selected.length; i++) {
  3524. text += selected[i][0] + ', ';
  3525. }
  3526. text = text.substring(0, text.length - 2);
  3527. alert(text);
  3528. });
  3529. });
  3530. &lt;/script&gt;
  3531. </pre>
  3532. </div>
  3533. <p>
  3534. Simulate single selections using checkboxes. The behavior will be similar to a multiselect with radio buttons except that the selected option can be deselected again.
  3535. </p>
  3536. <div class="example">
  3537. <script type="text/javascript">
  3538. $(document).ready(function() {
  3539. $('#example-simulate-single').multiselect({
  3540. onChange: function(option, checked) {
  3541. var values = [];
  3542. $('#example-simulate-single option').each(function() {
  3543. if ($(this).val() !== option.val()) {
  3544. values.push($(this).val());
  3545. }
  3546. });
  3547. $('#example-simulate-single').multiselect('deselect', values);
  3548. }
  3549. });
  3550. });
  3551. </script>
  3552. <select id="example-simulate-single" multiple="multiple">
  3553. <option value="1">Option 1</option>
  3554. <option value="2">Option 2</option>
  3555. <option value="3">Option 3</option>
  3556. <option value="4">Option 4</option>
  3557. <option value="5">Option 5</option>
  3558. <option value="6">Option 6</option>
  3559. </select>
  3560. </div>
  3561. <div class="highlight">
  3562. <pre class="prettyprint linenums">
  3563. &lt;script type=&quot;text/javascript&quot;&gt;
  3564. $(document).ready(function() {
  3565. $('#example-simulate-single').multiselect({
  3566. on: {
  3567. change: function(option, checked) {
  3568. var values = [];
  3569. $('#example-simulate-single option').each(function() {
  3570. if ($(this).val() !== option.val()) {
  3571. values.push($(this).val());
  3572. }
  3573. });
  3574. $('#example-simulate-single').multiselect('deselect', values);
  3575. }
  3576. }
  3577. });
  3578. });
  3579. &lt;/script&gt;
  3580. </pre>
  3581. </div>
  3582. <p>
  3583. Using a reset button together with a multiselect.
  3584. </p>
  3585. <div class="example">
  3586. <script type="text/javascript">
  3587. $(document).ready(function() {
  3588. $('#example-reset').multiselect();
  3589. $('#example-reset-form').on('reset', function() {
  3590. $('#example-reset option:selected').each(function() {
  3591. $(this).prop('selected', false);
  3592. })
  3593. $('#example-reset').multiselect('refresh');
  3594. });
  3595. });
  3596. </script>
  3597. <form class="btn-group" id="example-reset-form">
  3598. <div class="btn-group">
  3599. <select id="example-reset" multiple="multiple">
  3600. <option value="1">Option 1</option>
  3601. <option value="2">Option 2</option>
  3602. <option value="3">Option 3</option>
  3603. <option value="4">Option 4</option>
  3604. <option value="5">Option 5</option>
  3605. <option value="6">Option 6</option>
  3606. </select>
  3607. <button type="reset" id="example-reset-button" class="btn btn-default">Reset</button>
  3608. </div>
  3609. </form>
  3610. </div>
  3611. <div class="highlight">
  3612. <pre class="prettyprint linenums">
  3613. &lt;script type=&quot;text/javascript&quot;&gt;
  3614. $(document).ready(function() {
  3615. $('#example-reset').multiselect();
  3616. $('#example-reset-form').on('reset', function() {
  3617. $('#example-reset option:selected').each(function() {
  3618. $(this).prop('selected', false);
  3619. })
  3620. $('#example-reset').multiselect('refresh');
  3621. });
  3622. });
  3623. &lt;/script&gt;
  3624. &lt;form class=&quot;btn-group&quot; id=&quot;example-reset-form&quot;&gt;
  3625. &lt;div class=&quot;btn-group&quot;&gt;
  3626. &lt;select id=&quot;example-reset&quot; multiple=&quot;multiple&quot;&gt;
  3627. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  3628. &lt;option value=&quot;2&quot;&gt;Option 2&lt;/option&gt;
  3629. &lt;option value=&quot;3&quot;&gt;Option 3&lt;/option&gt;
  3630. &lt;option value=&quot;4&quot;&gt;Option 4&lt;/option&gt;
  3631. &lt;option value=&quot;5&quot;&gt;Option 5&lt;/option&gt;
  3632. &lt;option value=&quot;6&quot;&gt;Option 6&lt;/option&gt;
  3633. &lt;/select&gt;
  3634. &lt;button type=&quot;reset&quot; id=&quot;example-reset-button&quot; class=&quot;btn btn-default&quot;&gt;Reset&lt;/button&gt;
  3635. &lt;/div&gt;
  3636. &lt;/form&gt;
  3637. </pre>
  3638. </div>
  3639. <p>
  3640. Multiselect can also be used in modals:
  3641. </p>
  3642. <div class="example">
  3643. <script type="text/javascript">
  3644. $(document).ready(function() {
  3645. $('#example-modal').multiselect();
  3646. });
  3647. </script>
  3648. <button class="btn btn-default" data-toggle="modal" data-target="#example-modal-modal">Launch modal</button>
  3649. <div class="modal fade" id="example-modal-modal">
  3650. <div class="modal-dialog">
  3651. <div class="modal-content">
  3652. <div class="modal-header">
  3653. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  3654. <h4 class="modal-title">Bootstrap Multiselect</h4>
  3655. </div>
  3656. <div class="modal-body">
  3657. <select id="example-modal" multiple="multiple">
  3658. <option value="1">Option 1</option>
  3659. <option value="2">Option 2</option>
  3660. <option value="3">Option 3</option>
  3661. <option value="4">Option 4</option>
  3662. <option value="5">Option 5</option>
  3663. <option value="6">Option 6</option>
  3664. </select>
  3665. </div>
  3666. </div>
  3667. </div>
  3668. </div>
  3669. </div>
  3670. <div class="highlight">
  3671. <pre class="prettyprint linenums">
  3672. &lt;script type=&quot;text/javascript&quot;&gt;
  3673. $(document).ready(function() {
  3674. $('#example-modal').multiselect();
  3675. });
  3676. &lt;/script&gt;
  3677. &lt;button class=&quot;btn btn-default&quot; data-toggle=&quot;modal&quot; data-target=&quot;#example-modal-modal&quot;&gt;Launch modal&lt;/button&gt;
  3678. &lt;div class=&quot;modal fade&quot; id=&quot;example-modal-modal&quot;&gt;
  3679. &lt;div class=&quot;modal-dialog&quot;&gt;
  3680. &lt;div class=&quot;modal-content&quot;&gt;
  3681. &lt;div class=&quot;modal-header&quot;&gt;
  3682. &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;&times;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Close&lt;/span&gt;&lt;/button&gt;
  3683. &lt;h4 class=&quot;modal-title&quot;&gt;Bootstrap Multiselect&lt;/h4&gt;
  3684. &lt;/div&gt;
  3685. &lt;div class=&quot;modal-body&quot;&gt;
  3686. &lt;select id=&quot;example-modal&quot; multiple=&quot;multiple&quot;&gt;
  3687. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  3688. &lt;option value=&quot;2&quot;&gt;Option 2&lt;/option&gt;
  3689. &lt;option value=&quot;3&quot;&gt;Option 3&lt;/option&gt;
  3690. &lt;option value=&quot;4&quot;&gt;Option 4&lt;/option&gt;
  3691. &lt;option value=&quot;5&quot;&gt;Option 5&lt;/option&gt;
  3692. &lt;option value=&quot;6&quot;&gt;Option 6&lt;/option&gt;
  3693. &lt;/select&gt;
  3694. &lt;/div&gt;
  3695. &lt;/div&gt;
  3696. &lt;/div&gt;
  3697. &lt;/div&gt;
  3698. </pre>
  3699. </div>
  3700. <p>
  3701. An example of using multiselect in an accordion/collapse:
  3702. </p>
  3703. <p class="alert alert-info">
  3704. Note that the overflow of the <code>.panel</code> needs to be visible: <code>style="overflow:visible;"</code>. See the example below.
  3705. </p>
  3706. <div class="example">
  3707. <script type="text/javascript">
  3708. $(document).ready(function() {
  3709. $('#example-collapse').multiselect();
  3710. });
  3711. </script>
  3712. <div class="panel-group" id="example-collapse-accordion">
  3713. <div class="panel panel-default" style="overflow:visible;">
  3714. <div class="panel-heading">
  3715. <h4 class="panel-title">
  3716. <a data-toggle="collapse" data-parent="#example-collapse-accordion" href="#example-collapse-accordion-one">
  3717. Bootstrap Multiselect
  3718. </a>
  3719. </h4>
  3720. </div>
  3721. <div id="example-collapse-accordion-one" class="panel-collapse collapse in">
  3722. <div class="panel-body">
  3723. <select id="example-collapse" multiple="multiple">
  3724. <option value="1">Option 1</option>
  3725. <option value="2">Option 2</option>
  3726. <option value="3">Option 3</option>
  3727. <option value="4">Option 4</option>
  3728. <option value="5">Option 5</option>
  3729. <option value="6">Option 6</option>
  3730. </select>
  3731. </div>
  3732. </div>
  3733. </div>
  3734. </div>
  3735. </div>
  3736. <div class="highlight">
  3737. <pre class="prettyprint linenums">
  3738. &lt;script type=&quot;text/javascript&quot;&gt;
  3739. $(document).ready(function() {
  3740. $('#example-collapse').multiselect();
  3741. });
  3742. &lt;/script&gt;
  3743. &lt;div class=&quot;panel-group&quot; id=&quot;example-collapse-accordion&quot;&gt;
  3744. &lt;div class=&quot;panel panel-default&quot; style=&quot;overflow:visible;&quot;&gt;
  3745. &lt;div class=&quot;panel-heading&quot;&gt;
  3746. &lt;h4 class=&quot;panel-title&quot;&gt;
  3747. &lt;a data-toggle=&quot;collapse&quot; data-parent=&quot;#example-collapse-accordion&quot; href=&quot;#example-collapse-accordion-one&quot;&gt;
  3748. Bootstrap Multiselect
  3749. &lt;/a&gt;
  3750. &lt;/h4&gt;
  3751. &lt;/div&gt;
  3752. &lt;div id=&quot;example-collapse-accordion-one&quot; class=&quot;panel-collapse collapse in&quot;&gt;
  3753. &lt;div class=&quot;panel-body&quot;&gt;
  3754. &lt;select id=&quot;example-collapse&quot; multiple=&quot;multiple&quot;&gt;
  3755. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  3756. &lt;option value=&quot;2&quot;&gt;Option 2&lt;/option&gt;
  3757. &lt;option value=&quot;3&quot;&gt;Option 3&lt;/option&gt;
  3758. &lt;option value=&quot;4&quot;&gt;Option 4&lt;/option&gt;
  3759. &lt;option value=&quot;5&quot;&gt;Option 5&lt;/option&gt;
  3760. &lt;option value=&quot;6&quot;&gt;Option 6&lt;/option&gt;
  3761. &lt;/select&gt;
  3762. &lt;/div&gt;
  3763. &lt;/div&gt;
  3764. &lt;/div&gt;
  3765. &lt;/div&gt;
  3766. </pre>
  3767. </div>
  3768. <p>
  3769. The examples below are aimed to demonstrate the performance of several features when using a large number of options:
  3770. </p>
  3771. <ul>
  3772. <li>Using the select all option, <code>includeSelectAllOption</code> set to <code>true</code>.</li>
  3773. <li>Additionally using a filter, <code>enableFiltering</code> set to <code>true</code>.</li>
  3774. <li>Additionally using <code>enableClickableOptGroups</code>.</li>
  3775. <li>Resetting the multiselect.</li>
  3776. </ul>
  3777. <p class="alert alert-warning">
  3778. The below examples need to be activated. <b>Note that this may take some time!</b><br>
  3779. </p>
  3780. <p class="alert alert-info">
  3781. Use <input type="text" id="example-large-options" value="1000" style="width: 50px;margin: 0px 4px;"/> options: <button id="example-large-enable" class="btn btn-primary">Enable Examples</button>
  3782. </p>
  3783. <div id="example-large-error">
  3784. </div>
  3785. <div class="example">
  3786. <script type="text/javascript">
  3787. $(document).ready(function() {
  3788. $('#example-large-enable').on('click', function() {
  3789. var options = $('#example-large-options').val();
  3790. if (options < 1 || options > 5000) {
  3791. $('#example-large-error').html('<p class="alert alert-error">Choose between 1 and 5000 options!</p>');
  3792. }
  3793. else {
  3794. $('#example-large-includeSelectAllOption').html('');
  3795. $('#example-large-includeSelectAllOption-enableFiltering').html('');
  3796. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').html('');
  3797. $('#example-large-reset').html('');
  3798. for (var j = 0; j < options; j++) {
  3799. i = j + 1;
  3800. $('#example-large-includeSelectAllOption').append('<option value="' + i.toString() + '">Option ' + i.toString() + '</option>');
  3801. $('#example-large-includeSelectAllOption-enableFiltering').append('<option value="' + i.toString() + '">Option ' + i.toString() + '</option>');
  3802. var group = Math.floor(j/10) + 1;
  3803. var number = j % 10 + 1;
  3804. if (number === 1) {
  3805. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').append('<optgroup label="Group ' + group.toString() + '"></optgroup>');
  3806. }
  3807. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').append('<option value="' + group.toString() + '-' + number.toString() + '">Option ' + group.toString() + '.' + number.toString() + '</option>');
  3808. $('#example-large-reset').append('<option value="' + i.toString() + '">Option ' + i.toString() + '</option>');
  3809. }
  3810. $('#example-large-includeSelectAllOption').multiselect({
  3811. maxHeight: 200,
  3812. includeSelectAllOption: true
  3813. });
  3814. $('#example-large-includeSelectAllOption-enableFiltering').multiselect({
  3815. maxHeight: 200,
  3816. includeSelectAllOption: true,
  3817. enableFiltering: true
  3818. });
  3819. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').multiselect({
  3820. maxHeight: 200,
  3821. includeSelectAllOption: true,
  3822. enableFiltering: true,
  3823. enableClickableOptGroups: true
  3824. });
  3825. $('#example-large-reset').multiselect({
  3826. maxHeight: 200,
  3827. includeSelectAllOption: true
  3828. });
  3829. $('#example-large-reset-form').on('reset', function() {
  3830. $('#example-large-reset').multiselect('deselectAll', false);
  3831. $('#example-large-reset').multiselect('updateButtonText');
  3832. });
  3833. }
  3834. });
  3835. });
  3836. </script>
  3837. <div class="btn-toolbar" style="margin-bottom:12px;">
  3838. <div class="btn-group">
  3839. <select id="example-large-includeSelectAllOption" multiple="multiple">
  3840. <option value="1">Option 1</option>
  3841. </select>
  3842. </div>
  3843. </div>
  3844. <div class="btn-toolbar" style="margin-bottom:12px;">
  3845. <div class="btn-group">
  3846. <select id="example-large-includeSelectAllOption-enableFiltering" multiple="multiple">
  3847. <option value="1">Option 1</option>
  3848. </select>
  3849. </div>
  3850. </div>
  3851. <div class="btn-toolbar" style="margin-bottom:12px;">
  3852. <div class="btn-group">
  3853. <select id="example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups" multiple="multiple">
  3854. <option value="1">Option 1</option>
  3855. </select>
  3856. </div>
  3857. </div>
  3858. <form id="example-large-reset-form" style="margin-bottom:12px;">
  3859. <div class="btn-group">
  3860. <select id="example-large-reset" multiple="multiple">
  3861. <option value="1">Option 1</option>
  3862. </select>
  3863. <button type="reset" class="btn btn-default">Reset</button>
  3864. </div>
  3865. </form>
  3866. </div>
  3867. <div class="highlight">
  3868. <pre class="prettyprint linenums">
  3869. &lt;script type=&quot;text/javascript&quot;&gt;
  3870. $(document).ready(function() {
  3871. $('#example-large-enable').on('click', function() {
  3872. var options = $('#example-large-options').val();
  3873. if (options &lt; 1 || options &gt; 5000) {
  3874. $('#example-large-error').html('&lt;p class=&quot;alert alert-error&quot;&gt;Choose between 1 and 5000 options!&lt;/p&gt;');
  3875. }
  3876. else {
  3877. $('#example-large-includeSelectAllOption').html('');
  3878. $('#example-large-includeSelectAllOption-enableFiltering').html('');
  3879. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').html('');
  3880. $('#example-large-reset').html('');
  3881. for (var j = 0; j &lt; options; j++) {
  3882. i = j + 1;
  3883. $('#example-large-includeSelectAllOption').append('&lt;option value=&quot;' + i.toString() + '&quot;&gt;Option ' + i.toString() + '&lt;/option&gt;');
  3884. $('#example-large-includeSelectAllOption-enableFiltering').append('&lt;option value=&quot;' + i.toString() + '&quot;&gt;Option ' + i.toString() + '&lt;/option&gt;');
  3885. var group = Math.floor(j/10) + 1;
  3886. var number = j % 10 + 1;
  3887. if (number === 1) {
  3888. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').append('&lt;optgroup label=&quot;Group ' + group.toString() + '&quot;&gt;&lt;/optgroup&gt;');
  3889. }
  3890. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').append('&lt;option value=&quot;' + group.toString() + '-' + number.toString() + '&quot;&gt;Option ' + group.toString() + '.' + number.toString() + '&lt;/option&gt;');
  3891. $('#example-large-reset').append('&lt;option value=&quot;' + i.toString() + '&quot;&gt;Option ' + i.toString() + '&lt;/option&gt;');
  3892. }
  3893. $('#example-large-includeSelectAllOption').multiselect({
  3894. maxHeight: 200,
  3895. includeSelectAllOption: true
  3896. });
  3897. $('#example-large-includeSelectAllOption-enableFiltering').multiselect({
  3898. maxHeight: 200,
  3899. includeSelectAllOption: true,
  3900. enableFiltering: true
  3901. });
  3902. $('#example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups').multiselect({
  3903. maxHeight: 200,
  3904. includeSelectAllOption: true,
  3905. enableFiltering: true,
  3906. enableClickableOptGroups: true
  3907. });
  3908. $('#example-large-reset').multiselect({
  3909. maxHeight: 200,
  3910. includeSelectAllOption: true
  3911. });
  3912. $('#example-large-reset-form').on('reset', function() {
  3913. $('#example-large-reset').multiselect('deselectAll', false);
  3914. $('#example-large-reset').multiselect('updateButtonText');
  3915. });
  3916. }
  3917. });
  3918. });
  3919. &lt;/script&gt;
  3920. &lt;div class=&quot;btn-toolbar&quot; style=&quot;margin-bottom:12px;&quot;&gt;
  3921. &lt;div class=&quot;btn-group&quot;&gt;
  3922. &lt;select id=&quot;example-large-includeSelectAllOption&quot; multiple=&quot;multiple&quot;&gt;
  3923. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  3924. &lt;/select&gt;
  3925. &lt;/div&gt;
  3926. &lt;/div&gt;
  3927. &lt;div class=&quot;btn-toolbar&quot; style=&quot;margin-bottom:12px;&quot;&gt;
  3928. &lt;div class=&quot;btn-group&quot;&gt;
  3929. &lt;select id=&quot;example-large-includeSelectAllOption-enableFiltering&quot; multiple=&quot;multiple&quot;&gt;
  3930. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  3931. &lt;/select&gt;
  3932. &lt;/div&gt;
  3933. &lt;/div&gt;
  3934. &lt;div class=&quot;btn-toolbar&quot; style=&quot;margin-bottom:12px;&quot;&gt;
  3935. &lt;div class=&quot;btn-group&quot;&gt;
  3936. &lt;select id=&quot;example-large-includeSelectAllOption-enableFiltering-enableClickableOptGroups&quot; multiple=&quot;multiple&quot;&gt;
  3937. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  3938. &lt;/select&gt;
  3939. &lt;/div&gt;
  3940. &lt;/div&gt;
  3941. &lt;form id=&quot;example-large-reset-form&quot; style=&quot;margin-bottom:12px;&quot;&gt;
  3942. &lt;div class=&quot;btn-group&quot;&gt;
  3943. &lt;select id=&quot;example-large-reset&quot; multiple=&quot;multiple&quot;&gt;
  3944. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  3945. &lt;/select&gt;
  3946. &lt;button type=&quot;reset&quot; class=&quot;btn btn-default&quot;&gt;Reset&lt;/button&gt;
  3947. &lt;/div&gt;
  3948. &lt;/form&gt;
  3949. </pre>
  3950. </div>
  3951. <p>The following examples is aimed to demonstrate the performance of the <code>.multiselect('dataprovider', data)</code> for a large number of options.</p>
  3952. <p class="alert alert-warning">The below examples need to be activated. <b>Note that this may take some time!</b></p>
  3953. <p class="alert alert-info"><button id="example-large-dataprovider-button" class="btn btn-primary">Activate</button></p>
  3954. <div class="example">
  3955. <script type="text/javascript">
  3956. $(document).ready(function() {
  3957. var data = [];
  3958. for (var i = 0; i < 100; i++) {
  3959. var group = {label: 'Group ' + (i + 1), children: []};
  3960. for (var j = 0; j < 10; j++) {
  3961. group['children'].push({
  3962. label: 'Option ' + (i + 1) + '.' + (j + 1),
  3963. value: i + '-' + j
  3964. });
  3965. }
  3966. data.push(group);
  3967. }
  3968. $('#example-large-dataprovider-button').on('click', function() {
  3969. $('#example-large-dataprovider').multiselect({
  3970. maxHeight: 200
  3971. });
  3972. $('#example-large-dataprovider').multiselect('dataprovider', data);
  3973. });
  3974. });
  3975. </script>
  3976. <select id="example-large-dataprovider" multiple="multiple"></select>
  3977. </div>
  3978. <div class="highlight">
  3979. <pre class="prettyprint linenums">
  3980. $(document).ready(function() {
  3981. var data = [];
  3982. for (var i = 0; i < 100; i++) {
  3983. var group = {label: 'Group ' + (i + 1), children: []};
  3984. for (var j = 0; j < 10; j++) {
  3985. group['children'].push({
  3986. label: 'Option ' + (i + 1) + '.' + (j + 1),
  3987. value: i + '-' + j
  3988. });
  3989. }
  3990. data.push(group);
  3991. }
  3992. $('#example-large-dataprovider-button').on('click', function() {
  3993. $('#example-large-dataprovider').multiselect({
  3994. maxHeight: 200
  3995. });
  3996. $('#example-large-dataprovider').multiselect('dataprovider', data);
  3997. });
  3998. });
  3999. &lt;p class=&quot;alert alert-info&quot;&gt;&lt;button id=&quot;example-large-dataprovider-button&quot; class=&quot;btn btn-primary&quot;&gt;Activate&lt;/button&gt;&lt;/p&gt;
  4000. &lt;select id=&quot;example-large-dataprovider&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt;
  4001. </pre>
  4002. <p>
  4003. The following example illsutrates how to disable options using JavaScript.
  4004. </p>
  4005. <div class="example">
  4006. <script type="text/javascript">
  4007. $(document).ready(function() {
  4008. $('#example-disable-javascript').multiselect({
  4009. includeSelectAllOption: true
  4010. });
  4011. $('#example-disable-javascript-disable').on('click', function() {
  4012. var input = $('#example-disable-javascript-container input[value="3"]');
  4013. var option = $('#example-disable-javascript-container option[value="3"]');
  4014. input.prop('disabled', true);
  4015. option.prop('disabled', true);
  4016. input.parent('label').parent('a').parent('li').addClass('disabled');
  4017. });
  4018. $('#example-disable-javascript-check').on('click', function() {
  4019. var options = '';
  4020. $('#example-disable-javascript option:selected').each(function() {
  4021. options += $(this).val() + ', ';
  4022. });
  4023. alert(options.substr(0, options.length - 2));
  4024. });
  4025. });
  4026. </script>
  4027. <div class="btn-group" id="example-disable-javascript-container">
  4028. <select id="example-disable-javascript" multiple="multiple">
  4029. <option value="1">Option 1</option>
  4030. <option value="2">Option 2</option>
  4031. <option value="3">Option 3</option>
  4032. <option value="4">Option 4</option>
  4033. <option value="5">Option 5</option>
  4034. <option value="6">Option 6</option>
  4035. </select>
  4036. <button id="example-disable-javascript-disable" class="btn btn-primary">Disable an option!</button>
  4037. <button id="example-disable-javascript-check" class="btn btn-primary">Check</button>
  4038. </div>
  4039. </div>
  4040. <div class="highlight">
  4041. <pre class="prettyprint linenums">
  4042. $(document).ready(function() {
  4043. $('#example-disable-javascript').multiselect();
  4044. });
  4045. &lt;select id=&quot;example-disable-javascript&quot; multiple=&quot;multiple&quot;&gt;&lt;/select&gt;
  4046. </pre>
  4047. <div class="page-header">
  4048. <h2 id="post">Server-Side Processing</h2>
  4049. </div>
  4050. <p class="alert alert-warning">
  4051. The below example uses a PHP script to demonstrate Server-Side Processing. Therefore, the below example will not run online - <b>download the repository and try it on a local server</b>.
  4052. </p>
  4053. <p>
  4054. In order to receive the correct data after submitting the form, the used <code>select</code> has to have an appropriate name. Note that an <code>[]</code> needs to be appended to the name when using the <code>multiple</code> option/attribute. Per default, the checkboxes used within the multiselect will not be submitted, however, this can be changed by adapting <code>checkboxName</code>. The select all option as well as the text input used for the filter will not be submitted. As this may be useful, the name of the select all checkbox may be adapted using the <code>selectAllName</code> option. The value of the select all checkbox can be controlled by the <code>selectAllValue</code> option while the values of the remaining checkboxes correspond to the values used by the <code>option</code>'s of the original <code>select</code>.
  4055. </p>
  4056. <div class="example">
  4057. <script type="text/javascript">
  4058. $(document).ready(function() {
  4059. $('#example-post').multiselect({
  4060. includeSelectAllOption: true,
  4061. enableFiltering: true
  4062. });
  4063. });
  4064. </script>
  4065. <form class="form-horizontal" method="POST" action="post.php">
  4066. <div class="form-group">
  4067. <label class="col-sm-2 control-label">Multiselect</label>
  4068. <div class="col-sm-10">
  4069. <select id="example-post" name="multiselect[]" multiple="multiple">
  4070. <option value="1">Option 1</option>
  4071. <option value="2">Option 2</option>
  4072. <option value="3">Option 3</option>
  4073. <option value="4">Option 4</option>
  4074. <option value="5">Option 5</option>
  4075. <option value="6">Option 6</option>
  4076. </select>
  4077. </div>
  4078. </div>
  4079. <div class="form-group">
  4080. <label class="col-sm-2 control-label">Text Input</label>
  4081. <div class="col-sm-10">
  4082. <input type="text" name="text" class="form-control" placeholder="Text Input" />
  4083. </div>
  4084. </div>
  4085. <div class="form-group">
  4086. <div class="col-sm-offset-2 col-sm-10">
  4087. <div class="checkbox">
  4088. <label>
  4089. <input type="checkbox" name="checkbox"> Checkbox
  4090. </label>
  4091. </div>
  4092. </div>
  4093. </div>
  4094. <div class="form-group">
  4095. <div class="col-sm-offset-2 col-sm-10">
  4096. <div class="radio">
  4097. <label>
  4098. <input type="radio" name="radio"> Radio 1
  4099. </label>
  4100. </div>
  4101. <div class="radio">
  4102. <label>
  4103. <input type="radio" name="radio"> Radio 2
  4104. </label>
  4105. </div>
  4106. </div>
  4107. </div>
  4108. <div class="form-group">
  4109. <div class="col-sm-offset-2 col-sm-10">
  4110. <button type="submit" class="btn btn-default">Submit</button>
  4111. </div>
  4112. </div>
  4113. </form>
  4114. </div>
  4115. <div class="highlight">
  4116. <pre class="prettyprint linenums">
  4117. &lt;script type=&quot;text/javascript&quot;&gt;
  4118. $(document).ready(function() {
  4119. $('#example-post').multiselect({
  4120. includeSelectAllOption: true,
  4121. enableFiltering: true
  4122. });
  4123. });
  4124. &lt;/script&gt;
  4125. &lt;form class=&quot;form-horizontal&quot; method=&quot;POST&quot; action=&quot;post.php&quot;&gt;
  4126. &lt;div class=&quot;form-group&quot;&gt;
  4127. &lt;label class=&quot;col-sm-2 control-label&quot;&gt;Multiselect&lt;/label&gt;
  4128. &lt;div class=&quot;col-sm-10&quot;&gt;
  4129. &lt;select id=&quot;example-post&quot; name=&quot;multiselect[]&quot; multiple=&quot;multiple&quot;&gt;
  4130. &lt;option value=&quot;1&quot;&gt;Option 1&lt;/option&gt;
  4131. &lt;option value=&quot;2&quot;&gt;Option 2&lt;/option&gt;
  4132. &lt;option value=&quot;3&quot;&gt;Option 3&lt;/option&gt;
  4133. &lt;option value=&quot;4&quot;&gt;Option 4&lt;/option&gt;
  4134. &lt;option value=&quot;5&quot;&gt;Option 5&lt;/option&gt;
  4135. &lt;option value=&quot;6&quot;&gt;Option 6&lt;/option&gt;
  4136. &lt;/select&gt;
  4137. &lt;/div&gt;
  4138. &lt;/div&gt;
  4139. &lt;div class=&quot;form-group&quot;&gt;
  4140. &lt;label class=&quot;col-sm-2 control-label&quot;&gt;Text Input&lt;/label&gt;
  4141. &lt;div class=&quot;col-sm-10&quot;&gt;
  4142. &lt;input type=&quot;text&quot; name=&quot;text&quot; class=&quot;form-control&quot; placeholder=&quot;Text Input&quot; /&gt;
  4143. &lt;/div&gt;
  4144. &lt;/div&gt;
  4145. &lt;div class=&quot;form-group&quot;&gt;
  4146. &lt;div class=&quot;col-sm-offset-2 col-sm-10&quot;&gt;
  4147. &lt;div class=&quot;checkbox&quot;&gt;
  4148. &lt;label&gt;
  4149. &lt;input type=&quot;checkbox&quot; name=&quot;checkbox&quot;&gt; Checkbox
  4150. &lt;/label&gt;
  4151. &lt;/div&gt;
  4152. &lt;/div&gt;
  4153. &lt;/div&gt;
  4154. &lt;div class=&quot;form-group&quot;&gt;
  4155. &lt;div class=&quot;col-sm-offset-2 col-sm-10&quot;&gt;
  4156. &lt;div class=&quot;radio&quot;&gt;
  4157. &lt;label&gt;
  4158. &lt;input type=&quot;radio&quot; name=&quot;radio&quot;&gt; Radio 1
  4159. &lt;/label&gt;
  4160. &lt;/div&gt;
  4161. &lt;div class=&quot;radio&quot;&gt;
  4162. &lt;label&gt;
  4163. &lt;input type=&quot;radio&quot; name=&quot;radio&quot;&gt; Radio 2
  4164. &lt;/label&gt;
  4165. &lt;/div&gt;
  4166. &lt;/div&gt;
  4167. &lt;/div&gt;
  4168. &lt;div class=&quot;form-group&quot;&gt;
  4169. &lt;div class=&quot;col-sm-offset-2 col-sm-10&quot;&gt;
  4170. &lt;button type=&quot;submit&quot; class=&quot;btn btn-default&quot;&gt;Submit&lt;/button&gt;
  4171. &lt;/div&gt;
  4172. &lt;/div&gt;
  4173. &lt;/form&gt;
  4174. </pre>
  4175. </div>
  4176. <div class="page-header">
  4177. <h2 id="keyboard-support">Keyboard Support</h2>
  4178. </div>
  4179. <table class="table table-striped">
  4180. <tbody>
  4181. <tr>
  4182. <td><code>Tab</code></td>
  4183. <td>As with other form elements, <code>Tab</code> is used to switch to the next form elements. <code>Tab</code> can be used when the dropdown is opened as well as when it is closed.</td>
  4184. </tr>
  4185. <tr>
  4186. <td><code>Space/Enter</code></td>
  4187. <td><code>Space</code> or <code>Enter</code> is used to open the dropdown and select options. After a multiselect is in focus, pressing <code>Space</code> or <code>Enter</code> will open the dropdown. Then, the options can be traversed using arrow up and down.</td>
  4188. </tr>
  4189. <tr>
  4190. <td><code>Arrow Up/Arrow Down</code></td>
  4191. <td>Used to traverse the options after opening the dropdown. An option can be selected using <code>Space</code> or <code>Enter</code>.</td>
  4192. </tr>
  4193. </tbody>
  4194. </table>
  4195. <div class="page-header">
  4196. <h2 id="faq">Frequently Asked Questions</h2>
  4197. </div>
  4198. <dl>
  4199. <dt id="how-to-contribute">How to contribute?</dt>
  4200. <dd>
  4201. Pull requests to add additional feature or fix known bugs are always welcome! However, to make it easy for me to review and merge your pull request, the following guidelines should be considered:
  4202. <ul>
  4203. <li>Add one pull request per feature/fix. Otherwise, I cannot guarantee that I will merge the pull request.</li>
  4204. <li>Always document your changes. If new features are added, new options or methods should be added to the documentation (<code>index.html</code>) and appropriate examples should be added.</li>
  4205. <li>Add a throrough description to your pull request - yes, I am able to read your code, however, reading your description may speed up things!</li>
  4206. <li>Add comments to your code.</li>
  4207. </ul>
  4208. A full list of contributors can be found <a href="https://github.com/davidstutz/bootstrap-multiselect/graphs/contributors">here</a>.
  4209. </dd>
  4210. <dt>How about older browsers as for example Internet Explorer 6, 7 and 8?</dt>
  4211. <dd>
  4212. With version 2.0, jQuery no longer supports the older IE versions. Nevertheless, the plugin should run as expected using the 1.x branch of jQuery. See <a href="http://blog.jquery.com/2013/04/18/jquery-2-0-released/">here</a> for details.
  4213. </dd>
  4214. <dt>May I use the plugin in a commercial project (e.g. a commercial Wordpress/Joomla theme)?</dt>
  4215. <dd>
  4216. The plugin is dual licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License v2.0</a> and the <a href="http://opensource.org/licenses/BSD-3-Clause">BSD 3-Clause License</a>. The BSD 3-Clause License allows to use the plugin in commercial projects as long as all source files associated with this plugin retain the copyright notice.
  4217. </dd>
  4218. <dt>Using <code>return false;</code> within the <code>onChange</code> option does not prevent the option from being selected/deselected ...</dt>
  4219. <dd>
  4220. The <code>return</code> statement within the <code>onChange</code> method has no influence on the result. For preventing an option from being deselected or selected have a look at the examples in the <a href="#further-examples">Further Examples</a> section.
  4221. </dd>
  4222. <dt>How to change the button class depending on the number of selected options?</dt>
  4223. <dd>
  4224. This issue is addressed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/332">332</a>.
  4225. </dd>
  4226. <dt>Why does the plugin crash when using <code>.multiselect('select', value);</code> or <code>.multiselect('deselect', value);</code>?</dt>
  4227. <dd>
  4228. This may be caused when the class used for the <code>select</code> occurs for other elements, as well. In addition this may be caused if the multiselect has the class <code>.multiselect</code>. See <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/330">#330</a>.
  4229. </dd>
  4230. <dt>How to check whether filtering all options resulted no options being displayed (except the select all option)?</dt>
  4231. <dd>
  4232. This issue is discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/317">#317</a>.
  4233. </dd>
  4234. <dt>How to use multiple plugin instances running single selections on one page?</dt>
  4235. <dd>
  4236. There is a minor bug when using multiple plugin instances with single selection on one page. The bug is described here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/331">#331</a>. A possible fix is suggested here: <a href="https://github.com/davidstutz/bootstrap-multiselect/pull/336">#336</a>.
  4237. </dd>
  4238. <dt>How to use the plugin within a <code>form.form-inline</code>?</dt>
  4239. <dd>
  4240. This issue is addressed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/322">#322</a>
  4241. </dd>
  4242. <dt>Using jQuery, how to get the selected options dynamically?</dt>
  4243. <dd>
  4244. <pre class="linenums prettyprint">
  4245. // get all option elements
  4246. $('#example option:selected');
  4247. // get all option element values
  4248. $('#example option:selected').map(function(a, item){return item.value;});
  4249. </pre>
  4250. </dd>
  4251. <dt>How to get the selected options using PHP?</dt>
  4252. <dd>
  4253. This issue is addressed here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/323">https://github.com/davidstutz/bootstrap-multiselect/issues/323</a>. Mainly there are two ways, either add a name to the <code>select</code>:
  4254. <pre class="linenums prettyprint">
  4255. &lt;select id="example2" multiple="multiple" name="select[]"&gt;&lt;/select&gt;
  4256. </pre>
  4257. <p>Or add an appropriate name to the checkboxes:</p>
  4258. <pre class="linenums prettyprint">
  4259. $('#example2').multiselect({
  4260. checkboxName: 'multiselect[]'
  4261. });
  4262. </pre>
  4263. </dd>
  4264. <dt>Why does the plugin not work in Chrome for Mobile?</dt>
  4265. <dd>
  4266. This may be caused by several reasons one of which is described and resolved here: <a href="https://github.com/davidstutz/bootstrap-multiselect/pull/223">#223</a>.
  4267. </dd>
  4268. <dt>How to underline the searched text when using the filter?</dt>
  4269. <dd>
  4270. This issue is discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/309" target="_blank">#309</a>.
  4271. </dd>
  4272. <dt>How to hide the checkboxes?</dt>
  4273. <dd>
  4274. A related issue is discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/205" target="_blank">#205</a> and includes a possible solution when using CSS to hide the checkboxes:
  4275. <pre class="prettyprint linenums">
  4276. .multiselect-container input {
  4277. display: none
  4278. }
  4279. </pre>
  4280. </dd>
  4281. <dt>How to use Bootstrap Multiselect using <code>$.validate</code>?</dt>
  4282. <dd>
  4283. This topic is discussed in issue <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/347">#347</a>. The fix suggested is as follows:
  4284. <pre class="prettyprint linenums">
  4285. var $form = $("#myForm");
  4286. var validator = $form.data('validator');
  4287. validator.settings.ignore = ':hidden:not(".multiselect")';
  4288. </pre>
  4289. </dd>
  4290. <dt>How to prevent the plugin from selecting the first option in single select mode?</dt>
  4291. <dd>
  4292. This issue is mainly due to the default behavior of most browsers. A workaround can be found here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/129">#129</a>.
  4293. </dd>
  4294. <dt>Which are the minimum required components of Twitter Botostrap to get the plugin working?</dt>
  4295. <dd>
  4296. The plugin needs at least the styles for forms and dropdowns. In addition the JavaScript dropdown plugin from Twitter Bootstrap is required. Details can be found here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/344">#344</a>.
  4297. </dd>
  4298. <dt>How to use the <code>.multiselect('dataprovider', data)</code> method?</dt>
  4299. <dd>
  4300. Have a look at the <a href="#methods">Methods</a> section. In the past, there has been some confusion about how the method handles option groups. If the documentation does not help you, have a look at the issue tracker, as for example issue <a target="_blank" href="https://github.com/davidstutz/bootstrap-multiselect/issues/356">#356</a>.
  4301. </dd>
  4302. <dt>A <code>type="reset"</code> button does not refresh the multiselect, what to do?</dt>
  4303. <dd>
  4304. Have a look at the <a href="#further-examples">Further Examples</a> section (in addition, issue <a target="_blank" href="https://github.com/davidstutz/bootstrap-multiselect/issues/360">360</a> discussed this).
  4305. </dd>
  4306. <dt>Using multiple <code>select</code>'s in single selection mode with <code>option</code>'s sharing values across the different <code>select</code>'s.</dt>
  4307. <dd>
  4308. This issue is discussed in detail here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/362">#362</a>. A simple solution is to use different option values for the option <code>checkboxName</code>:
  4309. <pre class="prettyprint linenums">
  4310. $('.multiselect').multiselect({
  4311. checkboxName: _.uniqueId('multiselect_')
  4312. });
  4313. </pre>
  4314. where <code>_.uniqueId('multiselect_')</code> should be replaced with a random generator. Alternatively, a unique value for <code>checkboxName</code> can be used for each multiselect.
  4315. </dd>
  4316. <dt>How to avoid <code>TypeError: Cannot read property "toString" of ...</code>?</dt>
  4317. <dd>
  4318. This error may be thrown if <code>null</code> or <code>undefined</code> is provided as argument of <code>.multiselect('select', value)</code> or <code>.multiselect('deselect', value)</code>, see <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/386">#386</a>.
  4319. </dd>
  4320. <dt>Why is there no "uncheck all" option?</dt>
  4321. <dd>
  4322. This issue is discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/271">#271.</a>
  4323. </dd>
  4324. <dt>Esc does not close the dropdown?!</dt>
  4325. <dd>
  4326. This issue is discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/368">#368</a>. Currently, pressing <code>Esc</code> will not close the dropdown as there were some bugs with this.
  4327. </dd>
  4328. <dt>How to keep the dropdown open?</dt>
  4329. <dd>
  4330. This issue is discussed here: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/426">#426</a>.
  4331. </dd>
  4332. <dt>Why is the dropdown not showing (or only partly shown) within modals?</dt>
  4333. <dd>
  4334. This is a general issue not directly related to Bootstrap Multiselect: <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/455">#455</a>.
  4335. </dd>
  4336. <dt>How do add icons to the options (<a href="https://github.com/davidstutz/bootstrap-multiselect/issues/475">#475</a>)?</dt>
  4337. <dd>
  4338. Adapt the <code>optionLabel</code> option as follows:
  4339. <pre class="prettyprint linenums">
  4340. optionLabel: function(element){
  4341. return $(element).attr('label') || $(element).html();
  4342. },
  4343. </pre>
  4344. </dd>
  4345. <dt>How to add a deselect all functionality (the inverse to the select all option)?</dt>
  4346. <dd>
  4347. This issue was discussed in the following pull request: <a href="https://github.com/davidstutz/bootstrap-multiselect/pull/487">#487</a>.
  4348. </dd>
  4349. <dt>How to bind object values using Knockout JS?</dt>
  4350. <dd>
  4351. This issue was discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/532">#532</a>.
  4352. </dd>
  4353. <dt>Options do net get updated when using Angular JS?</dt>
  4354. <dd>
  4355. This issues was discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/pull/519">#519</a>.
  4356. </dd>
  4357. </dl>
  4358. <div class="page-header">
  4359. <h2 id="known-issues">Known Issues</h2>
  4360. </div>
  4361. <dl>
  4362. <dt>Slow dropdown on Chrome 35.</dt>
  4363. <dd>
  4364. As discussed in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/268">#268</a>, certain versions seem to have some performance problems, especially Chrome 35.0.1916.114m.
  4365. </dd>
  4366. <dt>Using <code>maxHeight</code> results in the filter being not fixed at the top.</dt>
  4367. <dd>
  4368. See issue <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/396"></a>. Pull requests are welcome.
  4369. </dd>
  4370. </dl>
  4371. <div class="page-header">
  4372. <h2 id="license">License</h2>
  4373. </div>
  4374. <dl>
  4375. <dt>Apache License, Version 2.0</dt>
  4376. <dd>
  4377. <p>Copyright 2012 - 2014 David Stutz</p>
  4378. <p>
  4379. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0</a>.
  4380. </p>
  4381. <p>
  4382. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  4383. </p>
  4384. </dd>
  4385. <dt>BSD 3-Clause License</dt>
  4386. <dd>
  4387. <p>Copyright (c) 2012 - 2014 David Stutz</p>
  4388. <p>All rights reserved.</p>
  4389. <p>
  4390. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  4391. </p>
  4392. <ul>
  4393. <li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  4394. <li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4395. <li>Neither the name of David Stutz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  4396. </ul>
  4397. <p>
  4398. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4399. </p>
  4400. </dd>
  4401. </dl>
  4402. <hr>
  4403. <p>
  4404. &copy; 2012 - 2014
  4405. <a href="http://davidstutz.de">David Stutz</a> - dual licensed: <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License v2.0</a>, <a href="http://opensource.org/licenses/BSD-3-Clause">BSD 3-Clause License</a>
  4406. </p>
  4407. </div>
  4408. </div>
  4409. </div>
  4410. </body>
  4411. </html>