Fa'ase'e ile anotusi autu Fa'ase'e ile su'ega fa'amatalaga
Check

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:
const myModal = document.getElementById('myModal')
const myInput = document.getElementById('myInput')

myModal.addEventListener('shown.bs.modal', () => {
  myInput.focus()
})
O le aafiaga o le animation o lenei vaega e fa'alagolago i le su'esu'ega a le prefers-reduced-motionaufaasālalau. Va'ai le vaega fa'aitiitiga fa'aitiitiga oa matou pepa fa'aoga avanoa .

Faitau pea mo faʻataʻitaʻiga ma taʻiala faʻaoga.

Faataitaiga

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.

<div class="modal" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

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.

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

Fa'aola fa'atete'e

A fa'atutu le tua i le tulaga, e le tapunia le modal pe a kiliki i fafo. Kiliki le ki lalo e taumafai ai.

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
  Launch static backdrop modal
</button>

<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Understood</button>
      </div>
    </div>
  </div>
</div>

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.

E mafai foʻi ona e fatuina se taʻavale faʻapipiʻi lea e mafai ai ona taʻavale le tino modal e ala i le faʻaopoopo .modal-dialog-scrollablei le .modal-dialog.

<!-- Scrollable modal -->
<div class="modal-dialog modal-dialog-scrollable">
  ...
</div>

Tutotonu i luga

Fa'aopoopo .modal-dialog-centeredi .modal-dialogle fa'atūtonu i le ogatotonu le modal.

<!-- Vertically centered modal -->
<div class="modal-dialog modal-dialog-centered">
  ...
</div>

<!-- Vertically centered scrollable modal -->
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
  ...
</div>

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.

<div class="modal-body">
  <h5>Popover in a modal</h5>
  <p>This <a href="#" role="button" class="btn btn-secondary" data-bs-toggle="popover" title="Popover title" data-bs-content="Popover body content is set in this attribute.">button</a> triggers a popover on click.</p>
  <hr>
  <h5>Tooltips in a modal</h5>
  <p><a href="#" data-bs-toggle="tooltip" title="Tooltip">This link</a> and <a href="#" data-bs-toggle="tooltip" title="Tooltip">that link</a> have tooltips on hover.</p>
</div>

Fa'aaogaina o le fa'asologa

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.

<div class="modal-body">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-4">.col-md-4</div>
      <div class="col-md-4 ms-auto">.col-md-4 .ms-auto</div>
    </div>
    <div class="row">
      <div class="col-md-3 ms-auto">.col-md-3 .ms-auto</div>
      <div class="col-md-2 ms-auto">.col-md-2 .ms-auto</div>
    </div>
    <div class="row">
      <div class="col-md-6 ms-auto">.col-md-6 .ms-auto</div>
    </div>
    <div class="row">
      <div class="col-sm-9">
        Level 1: .col-sm-9
        <div class="row">
          <div class="col-8 col-sm-6">
            Level 2: .col-8 .col-sm-6
          </div>
          <div class="col-4 col-sm-6">
            Level 2: .col-4 .col-sm-6
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

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-bs-* e fesuia'i ai mea o lo'o i totonu o le fa'ata'atia e 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.

html
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@mdo">Open modal for @mdo</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@fat">Open modal for @fat</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@getbootstrap">Open modal for @getbootstrap</button>

<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">New message</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <form>
          <div class="mb-3">
            <label for="recipient-name" class="col-form-label">Recipient:</label>
            <input type="text" class="form-control" id="recipient-name">
          </div>
          <div class="mb-3">
            <label for="message-text" class="col-form-label">Message:</label>
            <textarea class="form-control" id="message-text"></textarea>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Send message</button>
      </div>
    </div>
  </div>
</div>
const exampleModal = document.getElementById('exampleModal')
exampleModal.addEventListener('show.bs.modal', event => {
  // Button that triggered the modal
  const button = event.relatedTarget
  // Extract info from data-bs-* attributes
  const recipient = button.getAttribute('data-bs-whatever')
  // If necessary, you could initiate an AJAX request here
  // and then do the updating in a callback.
  //
  // Update the modal's content.
  const modalTitle = exampleModal.querySelector('.modal-title')
  const modalBodyInput = exampleModal.querySelector('.modal-body input')

  modalTitle.textContent = `New message to ${recipient}`
  modalBodyInput.value = recipient
})

Fa'asolo i le va o auala

Fa'asolo i le va o le tele o auala faʻatasi ma se faʻaogaina poto o le data-bs-targetma data-bs-toggleuiga. Mo se fa'ata'ita'iga, e mafai ona e fesuia'i se fa'aupuga e toe setiina ai upu fa'amaufa'ailoga mai totonu o se fa'ailoga ua matala ile fa'ailoga. Fa'amolemole maitau le tele o auala e le mafai ona tatalaina i le taimi e tasi -o lenei metotia e naʻo le fesuiaʻi i le va o auala eseese e lua.

Tatala le auala muamua
html
<div class="modal fade" id="exampleModalToggle" aria-hidden="true" aria-labelledby="exampleModalToggleLabel" tabindex="-1">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalToggleLabel">Modal 1</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        Show a second modal and hide this one with the button below.
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" data-bs-target="#exampleModalToggle2" data-bs-toggle="modal">Open second modal</button>
      </div>
    </div>
  </div>
</div>
<div class="modal fade" id="exampleModalToggle2" aria-hidden="true" aria-labelledby="exampleModalToggleLabel2" tabindex="-1">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalToggleLabel2">Modal 2</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        Hide this modal and show the first with the button below.
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" data-bs-target="#exampleModalToggle" data-bs-toggle="modal">Back to first</button>
      </div>
    </div>
  </div>
</div>
<a class="btn btn-primary" data-bs-toggle="modal" href="#exampleModalToggle" role="button">Open first modal</a>

Suia le animation

O le $modal-fade-transformfesuiaiga e fuafua ai le suiga o le tulaga .modal-dialogaʻo leʻi oʻo i le modal fade-in animation, o le $modal-show-transformfesuiaiga e fuafua le suiga o .modal-dialogle i le pito o le modal fade-in animation.

Afai e te manaʻo mo se faʻataʻitaʻiga se faʻaoso-i totonu animation, e mafai ona e seti $modal-fade-transform: scale(.8).

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.

<div class="modal" tabindex="-1" aria-labelledby="..." aria-hidden="true">
  ...
</div>

Maualuluga malosi

Afai e suia le maualuga o se auala a'o tatala, e tatau ona e vala'au myModal.handleUpdate()e toe fetu'una'i le tulaga o le modal pe a aliali mai se ta'avale.

Avanoa

Ia mautinoa e faʻaopoopo aria-labelledby="...", faʻasino le ulutala modal, i .modal. 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. Manatua e te le mana'omia le fa'aopoopo role="dialog"talu ai ua uma ona matou fa'aopoopoina e ala i le JavaScript.

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 tolu lapopo'a fa'apitoa, e maua e ala i vasega suiga 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.

Tele Vasega Modal max-lautele
Laiti .modal-sm 300px
Fa'atonu Leai 500px
Tele .modal-lg 800px
Tele tele .modal-xl 1140px

O la matou fa'aoga fa'aletonu e aunoa ma le fa'avasegaina o le vasega o lo'o fa'atūina ai le fa'asologa o le lapopoa "medium".

<div class="modal-dialog modal-xl">...</div>
<div class="modal-dialog modal-lg">...</div>
<div class="modal-dialog modal-sm">...</div>

Fa'ata'otoga ata

O le isi fa'aletonu o le filifiliga lea e fa'apipi'i ai se fa'atagata e ufiufi ai le va'aiga a le tagata fa'aoga, e maua e ala i vasega fa'aopoopo e tu'u i luga o se .modal-dialog.

Vasega Avanoa
.modal-fullscreen I taimi uma
.modal-fullscreen-sm-down 576px
.modal-fullscreen-md-down 768px
.modal-fullscreen-lg-down 992px
.modal-fullscreen-xl-down 1200px
.modal-fullscreen-xxl-down 1400px
<!-- Full screen modal -->
<div class="modal-dialog modal-fullscreen-sm-down">
  ...
</div>

CSS

Fuafuaga

Fa'aopoopo i le v5.2.0

I le avea ai o se vaega o le faʻaogaina o suiga CSS a Bootstrap, ua faʻaogaina nei e le au faʻaoga suiga CSS faʻapitonuʻu i luga .modalma .modal-backdropmo le faʻaleleia o le taimi moni aganuʻu. O tau mo le CSS fesuiaiga e faʻatulagaina e ala i le Sass, o lea o loʻo lagolagoina pea le Sass customization.

  --#{$prefix}modal-zindex: #{$zindex-modal};
  --#{$prefix}modal-width: #{$modal-md};
  --#{$prefix}modal-padding: #{$modal-inner-padding};
  --#{$prefix}modal-margin: #{$modal-dialog-margin};
  --#{$prefix}modal-color: #{$modal-content-color};
  --#{$prefix}modal-bg: #{$modal-content-bg};
  --#{$prefix}modal-border-color: #{$modal-content-border-color};
  --#{$prefix}modal-border-width: #{$modal-content-border-width};
  --#{$prefix}modal-border-radius: #{$modal-content-border-radius};
  --#{$prefix}modal-box-shadow: #{$modal-content-box-shadow-xs};
  --#{$prefix}modal-inner-border-radius: #{$modal-content-inner-border-radius};
  --#{$prefix}modal-header-padding-x: #{$modal-header-padding-x};
  --#{$prefix}modal-header-padding-y: #{$modal-header-padding-y};
  --#{$prefix}modal-header-padding: #{$modal-header-padding}; // Todo in v6: Split this padding into x and y
  --#{$prefix}modal-header-border-color: #{$modal-header-border-color};
  --#{$prefix}modal-header-border-width: #{$modal-header-border-width};
  --#{$prefix}modal-title-line-height: #{$modal-title-line-height};
  --#{$prefix}modal-footer-gap: #{$modal-footer-margin-between};
  --#{$prefix}modal-footer-bg: #{$modal-footer-bg};
  --#{$prefix}modal-footer-border-color: #{$modal-footer-border-color};
  --#{$prefix}modal-footer-border-width: #{$modal-footer-border-width};
  
  --#{$prefix}backdrop-zindex: #{$zindex-modal-backdrop};
  --#{$prefix}backdrop-bg: #{$modal-backdrop-bg};
  --#{$prefix}backdrop-opacity: #{$modal-backdrop-opacity};
  

Sass fesuiaiga

$modal-inner-padding:               $spacer;

$modal-footer-margin-between:       .5rem;

$modal-dialog-margin:               .5rem;
$modal-dialog-margin-y-sm-up:       1.75rem;

$modal-title-line-height:           $line-height-base;

$modal-content-color:               null;
$modal-content-bg:                  $white;
$modal-content-border-color:        var(--#{$prefix}border-color-translucent);
$modal-content-border-width:        $border-width;
$modal-content-border-radius:       $border-radius-lg;
$modal-content-inner-border-radius: subtract($modal-content-border-radius, $modal-content-border-width);
$modal-content-box-shadow-xs:       $box-shadow-sm;
$modal-content-box-shadow-sm-up:    $box-shadow;

$modal-backdrop-bg:                 $black;
$modal-backdrop-opacity:            .5;

$modal-header-border-color:         var(--#{$prefix}border-color);
$modal-header-border-width:         $modal-content-border-width;
$modal-header-padding-y:            $modal-inner-padding;
$modal-header-padding-x:            $modal-inner-padding;
$modal-header-padding:              $modal-header-padding-y $modal-header-padding-x; // Keep this for backwards compatibility

$modal-footer-bg:                   null;
$modal-footer-border-color:         $modal-header-border-color;
$modal-footer-border-width:         $modal-header-border-width;

$modal-sm:                          300px;
$modal-md:                          500px;
$modal-lg:                          800px;
$modal-xl:                          1140px;

$modal-fade-transform:              translate(0, -50px);
$modal-show-transform:              none;
$modal-transition:                  transform .3s ease-out;
$modal-scale-transform:             scale(1.02);

Ta'amilosaga

E fa'atupuina $breakpointsfa'afanua fa'afanua ma se matasele i scss/_modal.scss.

@each $breakpoint in map-keys($grid-breakpoints) {
  $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  $postfix: if($infix != "", $infix + "-down", "");

  @include media-breakpoint-down($breakpoint) {
    .modal-fullscreen#{$postfix} {
      width: 100vw;
      max-width: none;
      height: 100%;
      margin: 0;

      .modal-content {
        height: 100%;
        border: 0;
        @include border-radius(0);
      }

      .modal-header,
      .modal-footer {
        @include border-radius(0);
      }

      .modal-body {
        overflow-y: auto;
      }
    }
  }
}

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'amalo ai fo'i le amio ta'avale fa'aletonu 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 auala.

E ala i fa'amaumauga uiga

Toggle

Fa'agaoioia se faiga e aunoa ma le tusia o le JavaScript. Seti data-bs-toggle="modal"i luga o se elemene e pulea, pei o se faamau, faatasi ai ma se data-bs-target="#foo"po href="#foo"o le taulaʻi i se faiga faʻapitoa e fesuiaʻi.

<button type="button" data-bs-toggle="modal" data-bs-target="#myModal">Launch modal</button>

Fa'ate'a

E mafai ona ausia le faʻateʻaina i le datauiga i luga o se faʻamau i totonu o le modal e pei ona faʻaalia i lalo:

<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>

poʻo luga o se faʻamau i fafo atu o le modal e faʻaaoga ai data-bs-targete pei ona faʻaalia i lalo:

<button type="button" class="btn-close" data-bs-dismiss="modal" data-bs-target="#my-modal" aria-label="Close"></button>
E ui o auala uma e lua e faʻateʻaina ai se faʻataʻitaʻiga o loʻo lagolagoina, ia manatua o le faʻateʻaina mai fafo o se auala e le fetaui ma le ARIA Authoring Practices Guide dialog (modal) pattern . Fai lenei mea i lou lava tulaga lamatia.

E ala i le JavaScript

Fausia se faiga faʻatasi ma se laina e tasi o le JavaScript:

const myModal = new bootstrap.Modal(document.getElementById('myModal'), options)
// or
const myModalAlternative = new bootstrap.Modal('#myModal', options)

Filifiliga

A'o mafai ona pasia filifiliga e ala i fa'amatalaga uiga po'o le JavaScript, e mafai ona e fa'aopoopoina se igoa filifiliga i le data-bs-, pei o le data-bs-animation="{value}". Ia mautinoa e sui le ituaiga mataupu o le igoa filifiliga mai le " CamelCase " i le " kebab-case " pe a pasia filifiliga e ala i faʻamatalaga uiga. Mo se faʻataʻitaʻiga, faʻaaoga data-bs-custom-class="beautifier"nai lo ledata-bs-customClass="beautifier" .

E pei o le Bootstrap 5.2.0, o vaega uma e lagolagoina se faʻataʻitaʻiga faʻaagaga faʻamaumauga uiga data-bs-confige mafai ona faʻapipiʻi faigofie vaega faʻapipiʻi o se manoa JSON. Afai ei ai se elemene data-bs-config='{"delay":0, "title":123}'ma data-bs-title="456"uiga, o le titletau mulimuli o le ai ai 456ma o faʻamatalaga faʻamatalaga uiga ese o le a faʻamalo ai tau o loʻo tuʻuina atu ile data-bs-config. E le gata i lea, o faʻamaumauga o loʻo i ai nei e mafai ona faʻapipiʻi JSON tau pei o data-bs-delay='{"show":0,"hide":150}'.

Igoa Ituaiga Fa'atonu Fa'amatalaga
backdrop boolean,'static' true E aofia ai se elemene fa'aola-backdrop. I le isi itu, faʻamaoti staticmo se faʻataʻitaʻiga e le tapunia le modal pe a kiliki.
focus boolean true Tu'u le taula'i ile faiga pe a amatalia.
keyboard boolean true Tapuni le auala pe a oomi le ki sola.

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 .

Va'ai la matou pepa JavaScript mo nisi fa'amatalaga .

Filifiliga pasi

Fa'agaoioia lau anotusi e fai ma fa'ata'ita'iga. Talia se filifiliga faitalia object.

const myModal = new bootstrap.Modal('#myModal', {
  keyboard: false
})
Metotia Fa'amatalaga
dispose Fa'aleaga le faiga o se elemene. (Ave'ese fa'amaumauga o lo'o teuina ile elemene DOM)
getInstance Metotia static lea e mafai ai ona e maua le faʻataʻitaʻiga faʻataʻitaʻiga e fesoʻotaʻi ma se elemene DOM.
getOrCreateInstance Metotia static e mafai ai ona e maua le faʻataʻitaʻiga faʻataʻitaʻiga e fesoʻotaʻi ma se elemene DOM, pe fatuina se mea fou pe a leʻi amataina.
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).
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).
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). E le gata i lea, e mafai ona e pasia se elemene DOM e avea o se finauga e mafai ona maua i mea faʻapitoa (e pei o le relatedTargetmeatotino). (ie const modalToggle = document.getElementById('toggleMyModal'); myModal.show(modalToggle).
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).

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">).

Mea na tupu Fa'amatalaga
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).
hidePrevented.bs.modal O lenei mea na tupu e faʻamalo pe a faʻaalia le modal, o lona tua o loʻo i staticai ma se kiliki i fafo atu o le modal e faia. E fa'amu foi le mea na tupu pe a oomi le ki sola ese ma keyboardseti le filifiliga i false.
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.
shown.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.
const myModalEl = document.getElementById('myModal')
myModalEl.addEventListener('hidden.bs.modal', event => {
  // do something...
})