Dropdowns nye toggleable, contextual overlays hena kadodowo ƒe xexlẽdzesiwo ɖeɖefia kple bubuwo. Wowɔ wo be woawɔ nu kple Bootstrap ƒe JavaScript ƒe kpeɖeŋutɔ si le eme. Wotrɔa asi le wo ŋu to asiƒoƒo ɖe wo dzi me, ke menye to asiƒoƒo ɖe wo dzi me o; esia nye nyametsotso si woɖo koŋ wɔ ɖe aɖaŋuwɔwɔ ŋu.
Wotu nusiwo wotsɔna ƒua gbe ɖe ame etɔ̃lia ƒe agbalẽdzraɖoƒe aɖe dzi, Popper.js , si naa teƒe si woate ŋu atrɔ asi le kple nukpɔkpɔ ƒe ʋɔtruwo didi. Kpɔ egbɔ be yede popper.min.js do ŋgɔ na Bootstrap ƒe JavaScript alo zã bootstrap.bundle.min.js/ bootstrap.bundle.jssi me Popper.js le. Popper.js mezãna tsɔ ɖoa dropdowns ɖe navbars me togbɔ be abe dynamic positioning mehiã o ene.
Ne èle míaƒe JavaScript tum tso dzɔtsoƒe la, ebia beutil.js .
Mɔnukpɔkpɔwo ƒe Mɔnukpɔkpɔ
WAI ARIA ƒe dzidzenu ɖe role="menu"widget ŋutɔŋutɔ gɔme , gake esia nye menu siwo le abe dɔwɔwɔ ene siwo ʋãa nuwɔna alo dɔwɔwɔwo koŋ. ARIA ƒe nuɖuɖuwo ate ŋu anye nusiwo le menu me, aɖaka me nu siwo le aɖaka me, radio ƒe abɔta ƒe nuɖuɖu ƒe akpawo, radio ƒe abɔta ƒe ƒuƒoƒo, kple menu suewo ko.
Gake wowɔ Bootstrap ƒe dropdowns ya be woanye esiwo wozãna le mɔ vovovowo nu eye woate ŋu azã wo ɖe nɔnɔme vovovowo kple dzesideɖoɖowo me. Le kpɔɖeŋu me, anya wɔ be woawɔ nusiwo woatsɔ ade eme siwo me nyatakaka bubuwo kple agbalẽviwo dzi kpɔkpɔ le, abe didiƒewo alo agbalẽvi siwo dzi woato age ɖe eme ene. Le susu sia ta la, Bootstrap mekpɔ mɔ (alo tsɔe kpe ɖe eŋu le eɖokui si) rolekple aria-nɔnɔme siwo hiã na ARIA ƒe nuɖuɖu vavãwo dometɔ aɖeke o. Ele be agbalẽŋlɔlawo ŋutɔ nade nɔnɔme siawo siwo le tẽ wu la eme.
Ke hã, Bootstrap tsɔa kpekpeɖeŋu si wotu ɖe eme kpena ɖe keyboard menu ƒe kadodo siwo wozãna ɖaa ƒe akpa gãtɔ ŋu, abe ŋutete si le ame si be wòaʋu to .dropdown-itemnu ɖekaɖekawo me to cursor keys zazã me eye nàtu menu la kple ESCkey la ene.
Kpɔɖeŋuwo
Kpe fli si le fli dzi ƒe toggle (wò abɔta alo kadodo) kple nu si le fli dzi la ɖe .dropdown, alo nu bubu si ɖe gbeƒã position: relative;. Woate ŋu aʋã dropdowns tso <a>alo <button>elements be wòasɔ ɖe wò nuhiahiã siwo ate ŋu adzɔ nu nyuie wu.
Abɔta ɖeka
Woateŋu atrɔ ɖekaɖeka ɖesiaɖe .btnwòazu dropdown toggle kple dzesidede tɔtrɔ aɖewo. Alesi nàte ŋu atsɔ wo ade dɔwɔwɔ me kple nu eveawo dometɔ ɖesiaɖee nye esi <button>:
Míezãa klass bubu sia tsɔ ɖea horizontal paddingsi le caret la ƒe akpa eveawo dzi kpɔtɔna 25% eye míeɖea margin-leftthat’s added for regular button dropdowns ɖa. Tɔtrɔ mawo kpee la nana caret la nɔa titina le abɔta si woma la me eye wònaa teƒe si woate ŋu aƒoe si ƒe lolome sɔ wu le abɔta gã la xa.
Le ŋutinya me la , ele be nu siwo le fli dzi la nanye kadodowo, gake meganye nenema le v4 gome o. Fifia àteŋu azã <button>elements le wò dropdowns me le wò tiatia me ɖe <a>s ko teƒe.
Le gɔmedzedzea me la, woɖoa nusiwo le tsia dzi la ɖe teƒe si le eɖokui si 100% tso etame kple edzila ƒe miame. Tsɔ kpe .dropdown-menu-rightɖe a .dropdown-menuŋu yi ɖusime ɖo fli si le fli dzi la ɖe ɖoɖo nu.
Tawo yi dzi! Woɖoa nusiwo wotsɔna ƒua gbe ɖe teƒe ɖeka akpe na Popper.js (negbe ne wole navbar me ko).
Menu me nyawo
Tanyawo
Tsɔ tanya kpee be nàde dzesi nuwɔna ƒe akpawo le nudzraɖoƒe ɖesiaɖe si le fli dzi.
Da nuŋɔŋlɔ ɖesiaɖe si le ablɔɖe me ɖe menu si dzi woŋlɔ nu ɖo la me eye nàzã dometsotso ƒe dɔwɔnuwo . De dzesii be anɔ eme be àhiã lolome ƒe atsyã bubuwo be nàxe mɔ ɖe nuɖuɖua ƒe kekeme nu.
Kpɔɖeŋu nuŋɔŋlɔ aɖewo siwo le sisim faa le nusiwo le fli dzi la me.
Eye esia nye kpɔɖeŋu nuŋɔŋlɔ si sɔ gbɔ wu.
Kpekpeɖeŋugbalẽviwo
De agbalẽvi aɖe nu siwo le fli dzi la me, alo nàwɔe wòazu nu siwo le fli dzi, eye nàzã margin alo padding utilities atsɔ ana teƒe manyomanyo si nèhiã lae.
To data attributes alo JavaScript dzi la, dropdown plugin la trɔa nya ɣaɣlawo (dropdown menus) to asitɔtrɔ le .showklass la ŋu le dzila ƒe xexlẽdzesi ƒe nu la dzi. Woɖoa data-toggle="dropdown"ŋu ɖe nɔnɔmea ŋu hena nutsotso siwo le fli dzi le dɔwɔwɔ ƒe ɖoɖo aɖe dzi, eyata anyo be nàzãe ɣesiaɣi.
Le mɔ̃ siwo ŋu woate ŋu aka asi nu ŋu le dzi la, ne èʋu nusi le tsia dzi la, etsɔa asiléƒe ƒuƒlu ( $.noop) kpena ɖe element mouseoverla ƒe viwo ŋu enumake . <body>This admittedly ugly hack is necessary to work around a quirk in iOS’ event delegation , si ne menye nenema o la, axe mɔ na tap le afisiafi le dropdown la godo be wòagaʋã code si xea dropdown la o. Ne wonya tu nusi wotsɔna ƒua gbe la ko la, woɖea asiléƒe ƒuƒlu siawo siwo wotsɔ kpe ɖe eŋu mouseoverla ɖa.
To nyatakaka ƒe nɔnɔmewo dzi
Tsɔe kpe data-toggle="dropdown"ɖe kadodo alo abɔta ŋu be nàtrɔ asi le nya aɖe ŋu.
To JavaScript dzi
Yɔ nusiwo le fli dzi la to JavaScript dzi:
data-toggle="dropdown"wogahiã kokoko
Eɖanye be èyɔ wò dropdown la to JavaScript dzi alo nèzã data-api boŋ o, data-toggle="dropdown"ehiã ɣesiaɣi be nànɔ dropdown la ƒe trigger element la dzi.
Tiatiawɔblɔɖewo
Woateŋu atsɔ tiatiawɔblɔɖewo ato nyatakaka ƒe nɔnɔmewo alo JavaScript dzi. Le nyatakaka ƒe nɔnɔmewo gome la, tsɔ tiatia ƒe ŋkɔ kpe ɖe data-, abe alesi wòle le data-offset="".
Ŋkɔ
Ƒomevi
Gᴐmedzeƒe
Nuɖᴐɖᴐ
offset ƒe ƒuƒoƒo
xexlẽdzesi | kaƒoƒo | wᴐ dᴐ
0.
Offset of the dropdown ne wotsɔe sɔ kple eƒe taɖodzinu. Ne èdi nyatakaka bubuwo la, kpɔ Popper.js ƒe offset docs .
ti kpo
boolean ƒe ƒuƒoƒo
nyateƒe
Ðe mɔ na Dropdown be wòatrɔ nenye be eƒo xlã nufiame ƒe akpaa. Ne èdi nyatakaka bubuwo la, kpɔ Popper.js ƒe flip docs .
Nufiame ƒe akpa si le nusiwo le fli dzi la me. Lɔ̃ ɖe 'toggle', 'parent', alo HTMLElement ƒe nufiame ƒe asixɔxɔwo dzi. Ne èdi nyatakaka bubuwo la, kpɔ Popper.js ƒe referenceObject docs .
ɖeɖe fia
ka
'ŋusẽtɔ'.
Le gɔmedzedzea me la, míezãa Popper.js hena teƒeɖoɖo si trɔna. Tsɔ esia wɔ dɔe kple static.
De dzesii ne boundarywoɖoe ɖe asixɔxɔ ɖesiaɖe si menye 'scrollParent', o la, wozãa atsyã position: staticla ɖe .dropdownnugoe la ŋu.
Mɔnuwo
Nuwɔmɔnu
Nuɖᴐɖᴐ
$().dropdown('toggle')
Trɔa navbar alo tabbed navigation aɖe si wona la ƒe dropdown menu.
$().dropdown('update')
Trɔ asi le element aɖe ƒe dropdown ƒe nɔƒe ŋu.
$().dropdown('dispose')
Egblẽa nu le element aɖe ƒe dropdown ŋu.
Nudzɔdzɔwo
Wodoa nudzɔdzɔ siwo katã le tsia dzi la ɖe .dropdown-menu's dzila ƒe akpaa dzi eye nɔnɔme aɖe le wo si relatedTarget, si ƒe asixɔxɔ nye toggling anchor element. hide.bs.dropdowneye hidden.bs.dropdownnudzɔdzɔwo ƒe nɔnɔme aɖe le wo si clickEvent(ne nudzɔdzɔ gbãtɔ ƒe ƒomevi nye click) si me Nudzɔdzɔ ƒe Nu le na nudzɔdzɔ si wozi.
Nudzᴐdzᴐ
Nuɖᴐɖᴐ
show.bs.dropdown
Nudzɔdzɔ sia doa dzo enumake ne woyɔ show instance mɔnu la.
shown.bs.dropdown
Woɖea nudzɔdzɔ sia ne wowɔ dropdown la be wòadze na zãla (alala CSS ƒe tɔtrɔwo, be woawu enu).
hide.bs.dropdown
Woɖea nudzɔdzɔ sia ɖa enumake ne woyɔ hide instance mɔnu la.
hidden.bs.dropdown
Woɖea nudzɔdzɔ sia ne wowu dropdown la ɣla ɖe zãla la nu (alala CSS ƒe tɔtrɔwo, be woawu enu).