Fa'aoga le Bootstrap's JavaScript modal plugin e fa'aopoopo ai fa'atalanoaga i lau 'upega tafa'ilagi mo pusa moli, fa'amatalaga a tagata fa'aoga, po'o mea fa'aaganu'u atoatoa.
E faapefea ona galue
Aʻo leʻi amataina le vaega faʻapitoa a Bootstrap, ia mautinoa e faitau mea nei ona ua suia talu ai nei a matou lisi lisi.
O faʻataʻitaʻiga e fausia i le HTML, CSS, ma le JavaScript. O lo'o fa'atulagaina i luga o isi mea uma i totonu o le pepa ma aveese le ta'ai mai le <body>fa'asolo ina ia mafai ai ona fa'asolo mea fa'apitoa.
O le kiliki i luga o le modal "backdrop" o le a otometi lava ona tapunia le modal.
E na'o le tasi le fa'amalama fa'ata'ita'i e lagolagoina e Bootstrap i le taimi. E le lagolagoina auala fa'akomepiuta aua matou te talitonu o ni fa'amatalaga leaga a tagata fa'aoga.
Fa'aoga tupe position: fixed, lea e mafai i nisi taimi ona fa'apitoa i lona fa'aliliuga. So'o se taimi e mafai ai, tu'u lau HTML HTML i se tulaga maualuga e aloese ai mai fa'alavelave fa'alavelave mai isi elemene. E ono tula'i mai ni fa'afitauli pe a fa'amomoe se .modali totonu o se isi elemene mautu.
Toe tasi, ona o position: fixed, o loʻo i ai ni faʻamatalaga faʻatasi ma le faʻaogaina o auala i luga o masini feaveaʻi. Va'ai la matou su'esu'ega lagolago docs mo fa'amatalaga.
Ona o le auala e faʻamatalaina ai e le HTML5 ona faʻaoga, o le autofocusuiga HTML e leai se aoga i Bootstrap modals. Ina ia ausia le aafiaga tutusa, faʻaaoga nisi JavaScript masani:
Faitau pea mo faʻataʻitaʻiga ma taʻiala faʻaoga.
Faataitaiga
Vaega tau tupe
O loʻo i lalo se faʻataʻitaʻiga faʻataʻitaʻiga masani (o lona uiga o lona positionma displayua faʻamalo). O lo'o aofia ai le fa'auluuluga fa'apena, tino fa'apitoa (mana'omia mo padding), ma le fa'avae fa'ailoga (filifiliga). Matou te talosaga atu ia e fa'aofia fa'aulutala fa'apena ma fa'ate'a gaioiga i so'o se taimi e mafai ai, po'o le tu'uina atu o se isi gaioiga fa'ate'a manino.
Suafa fa'atau
Modal body text e alu iinei.
Live demo
Su'e se fa'ata'ita'iga fa'atino galue i le kilikiina o le ki lalo. O le a fa'ase'e ifo i lalo ma mou atu mai le pito i luga o le itulau.
Modal title
Woohoo, you're reading this text in a modal!
Ta'avale anotusi umi
A o'o ina umi tele auala mo le va'aiga a le tagata fa'aoga po'o le masini, latou te ta'avale tuto'atasi mai le itulau lava ia. Taumafai le faʻataʻitaʻiga o loʻo i lalo e iloa ai le matou uiga.
Modal title
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
Tutotonu i luga
Fa'aopoopo .modal-dialog-centeredi .modal-dialogle fa'atūtonu i le ogatotonu le modal.
Modal title
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Tooltips ma popovers
Tooltips ma popovers e mafai ona tuʻuina i totonu o auala pe a manaʻomia. A tapunia auala, so'o se meafaigaluega ma popovers i totonu e otometi lava ona fa'ate'aina.
Fa'aaogā le faiga fa'asologa o Bootstrap i totonu o se fa'ata'ita'iga e ala i le fa'aputu .container-fluidi totonu o le .modal-body. Ona fa'aaoga lea o vasega masani fa'asologa o faiga e pei ona e faia i se isi lava mea.
Grids in modals
.col-md-4
.col-md-4 .ml-auto
.col-md-3 .ml-auto
.col-md-2 .ml-auto
.col-md-6 .ml-auto
Level 1: .col-sm-9
Level 2: .col-8 .col-sm-6
Level 2: .col-4 .col-sm-6
Feeseesea'iga tulaga fa'aoga
E i ai ni fa'amau fa'amau e fa'aoso uma le faiga tutusa ma ni mea e ese'ese teisi? Fa'aoga event.relatedTargetma uiga HTMLdata-* (atonu e ala i le jQuery ) e fesuia'i mea o lo'o i totonu o le modal fa'atatau i le fa'amau na kiliki.
O loʻo i lalo se faʻataʻitaʻiga ola ma faʻataʻitaʻiga HTML ma JavaScript. Mo nisi fa'amatalaga, faitau le modal events docs mo fa'amatalaga ile relatedTarget.
New message
<buttontype="button"class="btn btn-primary"data-toggle="modal"data-target="#exampleModal"data-whatever="@mdo">Open modal for @mdo</button><buttontype="button"class="btn btn-primary"data-toggle="modal"data-target="#exampleModal"data-whatever="@fat">Open modal for @fat</button><buttontype="button"class="btn btn-primary"data-toggle="modal"data-target="#exampleModal"data-whatever="@getbootstrap">Open modal for @getbootstrap</button><divclass="modal fade"id="exampleModal"tabindex="-1"role="dialog"aria-labelledby="exampleModalLabel"aria-hidden="true"><divclass="modal-dialog"role="document"><divclass="modal-content"><divclass="modal-header"><h5class="modal-title"id="exampleModalLabel">New message</h5><buttontype="button"class="close"data-dismiss="modal"aria-label="Close"><spanaria-hidden="true">×</span></button></div><divclass="modal-body"><form><divclass="form-group"><labelfor="recipient-name"class="col-form-label">Recipient:</label><inputtype="text"class="form-control"id="recipient-name"></div><divclass="form-group"><labelfor="message-text"class="col-form-label">Message:</label><textareaclass="form-control"id="message-text"></textarea></div></form></div><divclass="modal-footer"><buttontype="button"class="btn btn-secondary"data-dismiss="modal">Close</button><buttontype="button"class="btn btn-primary">Send message</button></div></div></div></div>
Aveese le animation
Mo auala e foliga mai nai lo le mou atu e matamata ai, aveese le .fadevasega mai lau faʻailoga faʻailoga.
Maualuluga malosi
Afai e suia le maualuga o se auala a'o tatala, e tatau ona e vala'au $('#myModal').modal('handleUpdate')e toe fetu'una'i le tulaga o le modal pe a aliali mai se ta'avale.
Avanoa
Ia mautinoa e faʻaopoopo role="dialog"ma aria-labelledby="...", faʻasino i le ulutala modal, i .modal, ma role="document"ia .modal-dialoglava. E le gata i lea, e mafai ona e tuʻuina atu se faʻamatalaga o lau faʻasalalauga faʻatasi ma aria-describedbyon .modal.
Fa'apipi'i ata YouTube
O le fa'apipi'iina o vitio YouTube i fa'aola e mana'omia ai le JavaScript fa'aopoopo ae le o le Bootstrap e otometi ai ona taofi le toe ta'alo ma sili atu. Va'ai lenei pou fesoasoani Stack Overflow mo nisi fa'amatalaga.
Fa'ailoga tetele
E lua lapopo'a filifiliga, e maua e ala i vasega modifier e tu'u i luga o se .modal-dialog. O nei lapopo'a e a'a i totonu i nisi o va'a e alofia ai fa'alava ta'ai i luga o va'aiga vaapiapi.
Large modal
...
Small modal
...
Fa'aoga
O le modal plugin e fesuia'i au mea natia pe a mana'omia, e ala i fa'amatalaga uiga po'o le JavaScript. E fa'aopoopoina fo'i .modal-openi le <body>fa'ato'a fa'aletonu le ta'avale amio ma fa'atupuina se .modal-backdrope tu'uina atu ai se vaega kiliki mo le fa'ate'aina o fa'aaliga fa'aalia pe a kiliki i fafo atu o le fa'ailoga.
E ala i fa'amaumauga uiga
Fa'agaoioia se faiga e aunoa ma le tusia o le JavaScript. Seti data-toggle="modal"i luga o se elemene e pulea, pei o se faamau, faatasi ai ma se data-target="#foo"po href="#foo"o le taulaʻi i se faiga faʻapitoa e fesuiaʻi.
E ala i le JavaScript
Valaau se modal ma id myModalma se laina e tasi o le JavaScript:
Filifiliga
O filifiliga e mafai ona pasia e ala i faʻamatalaga uiga poʻo le JavaScript. Mo fa'amatalaga uiga, fa'aopoopo le igoa filifiliga i le data-, pei o le data-backdrop="".
Igoa
Ituaiga
Fa'atonu
Fa'amatalaga
tuaa
boolean po'o le manoa'static'
moni
E aofia ai se elemene fa'aola-backdrop. I le isi itu, fa'amaoti staticmo se fa'ata'atia e le tapuni ai le auala ile kiliki.
piano
boolean
moni
Tapuni le auala pe a oomi le ki sola
taula'i
boolean
moni
Tu'u le taula'i ile faiga pe a amatalia.
fa'aali
boolean
moni
Fa'aalia le faiga pe'ā amata.
Metotia
Metotia ma suiga e le tutusa
O metotia API uma e le fetaui ma amata se suiga . Latou te toe fo'i atu i le tagata telefoni i le taimi lava e amata ai le suiga ae le'i uma . E le gata i lea, o le a le amanaʻiaina se auala e valaʻau ai i se vaega o suiga .
Fa'agaoioia lau anotusi e fai ma fa'ata'ita'iga. Talia se filifiliga faitalia object.
.modal('toggle')
Su'e ma le lima se faiga. Toe fo'i i le tagata vala'au a'o le'i fa'aalia pe natia le modal (fa'atusa a'o le'i tupu le shown.bs.modalpo'o le hidden.bs.modalmea na tupu).
.modal('show')
Tatala ma le lima se auala. Toe fo'i atu i le tagata vala'au a'o le'i fa'aalia moni le modal (fa'atusa a'o le'i tupu le shown.bs.modalmea na tupu).
.modal('hide')
Natia ma le lima se auala. Toe fo'i i le tagata vala'au a'o le'i natia moni le modal (fa'atusa a'o le'i tupu le hidden.bs.modalmea na tupu).
.modal('handleUpdate')
Toe fetu'una'i ma le lima le tulaga o le auala pe a suia le maualuga o le auala a'o tatala (fa'apea pe a aliali mai se ta'avale).
.modal('dispose')
Fa'aleaga le faiga o se elemene.
Mea na tutupu
O le vasega fa'apitoa a Bootstrap o lo'o fa'aalia ai ni nai mea na tutupu mo le fa'aogaina o galuega fa'atino. O mea faʻapitoa uma e faʻaumatia i le modal lava ia (ie i le <div class="modal">).
Ituaiga Mea
Fa'amatalaga
show.bs.modal
E mu vave lenei mea pe a showvalaʻau le auala faʻataʻitaʻiga. Afai e mafua mai i se kiliki, o le elemene kiliki e avanoa e avea ma relatedTargetmeatotino o le mea na tupu.
fa'aalia.bs.modal
O lenei mea na tupu e faʻamalo pe a faʻaalia le modal i le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa). Afai e mafua mai i se kiliki, o le elemene kiliki e avanoa e avea ma relatedTargetmeatotino o le mea na tupu.
hide.bs.modal
O lenei mea na tupu e faʻamalo vave pe a hidevalaʻau le auala faʻataʻitaʻiga.
hidden.bs.modal
O lenei mea e tupu pe a maeʻa ona natia le modal mai le tagata faʻaoga (o le a faʻatali mo suiga CSS e maeʻa).