Tīpoka ki te ihirangi matua Tīpoka ki te whakaterenga tuhinga
Check

Whakamahia te monohiko JavaScript a Bootstrap ki te taapiri i nga korero ki to papaanga mo nga pouaka rama, nga whakamohiotanga a nga kaiwhakamahi, me nga ihirangi tino ritenga ranei.

Pehea te mahi

I mua i te tiimata me te waahanga modal a Bootstrap, kia mohio koe ki te panui i nga mea e whai ake nei na te mea kua huri nga whiringa tahua.

  • Ka hangaia nga tauira ki te HTML, CSS, me te JavaScript. Ka tuuhia ki runga ake i nga mea katoa o te tuhinga ka tango i te panuku mai i te pukapuka kia panuku te <body>ihirangi aratau.
  • Ma te panui i te "papamuri" ka kati aunoa i te ahua.
  • Ka tautokohia e Bootstrap tetahi matapihi aratau i ia wa. Kaore i te tautokohia nga tikanga kohanga na te mea e whakapono ana matou he ngoikore nga wheako kaiwhakamahi.
  • Ka whakamahia position: fixede nga tauira, he ahua motuhake mo tana whakaputanga. I nga wa katoa ka taea, tuuhia to HTML modal ki te taumata teitei kia kore ai e pokanoa mai i etahi atu huānga. Ka raru pea koe i te wa e kohanga ana .modali tetahi atu huānga kua whakaritea.
  • Ano ano, na te mea position: fixed, kei reira etahi whakatupato me te whakamahi i nga tikanga i runga i nga taputapu pūkoro. Tirohia a maatau tuhinga tautoko tirotiro mo nga taipitopito.
  • Na te ahua o te HTML5 e whakaatu ana i ona tohu, kaore he painga o te autofocushuanga HTML ki nga tikanga Bootstrap. Hei whakatutuki i taua paanga, whakamahia etahi ritenga JavaScript:
const myModal = document.getElementById('myModal')
const myInput = document.getElementById('myInput')

myModal.addEventListener('shown.bs.modal', () => {
  myInput.focus()
})
Ko te awe hākoritanga o tēnei wāhanga e whakawhirinaki ana ki te prefers-reduced-motionuiui pāpāho. Tirohia te waahanga motini whakaheke o a maatau tuhinga whakaurunga .

Kia mau ki te panui mo nga whakaaturanga me nga aratohu whakamahi.

Tauira

Kei raro nei he tauira aratau patekoposition ( ko tona tikanga displaykua whakakorehia). Kei roto ko te pane aratau, te tinana aratau (e hiahiatia ana mo te padding), me te hiku aratau (he whiriwhiri). Ka tono matou kia whakaurua e koe nga pane aratau me nga mahi whakakore i nga wa katoa ka taea, me whakarato ranei i tetahi atu mahi whakakore.

<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>

Demo ora

Takahurihia he whakaaturanga aratau mahi ma te paatene i te paatene kei raro nei. Ka paheke ki raro ka memeha mai i te tihi o te wharangi.

<!-- 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>

Papamuri pateko

Ina tautuhia te papamuri ki te pateko, ka kore te aratau e kati ina paato ana ki waho. Patohia te paatene i raro nei hei whakamatau.

<!-- 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>

Te panuku i nga ihirangi roa

Ka roa rawa nga tikanga mo te tauranga tirohanga a te kaiwhakamahi, te taputapu ranei, ka panuku motuhake mai i te wharangi ake. Whakamātauria te demo i raro nei kia kite he aha te tikanga.

Ka taea hoki e koe te hanga i tetahi aratau panuku ka taea te panuku i te tinana aratau ma te taapiri atu .modal-dialog-scrollableki te .modal-dialog.

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

Pokapū poutū

Tāpirihia .modal-dialog-centeredki .modal-dialogte poutū poutū te aratau.

<!-- 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>

Nga aki utauta me nga popovers

Ka taea te whakanoho i nga aki taputapu me nga pouvers ki roto i nga tikanga e hiahiatia ana. Ina katia nga tikanga, ka whakakorea aunoatia nga aki taputapu me nga popovers o roto.

<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>

Te whakamahi i te matiti

Whakamahia te punaha matiti Bootstrap i roto i te aratau ma te kohanga .container-fluidi roto i te .modal-body. Na, whakamahia nga karaehe punaha matiti noa penei i a koe ki hea atu.

<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>

Te rereke i nga ihirangi aratau

He paihere o nga patene e whakaoho ana i te ahua kotahi me nga ihirangi paku rereke? Whakamahia event.relatedTargetme nga huanga HTMLdata-bs-* ki te rereke i nga ihirangi o te aratau i runga i te paatene i paatohia.

Kei raro ko te demo ora e whai ana i te tauira HTML me JavaScript. Mo etahi atu korero, panuihia nga tuhinga takahanga modal mo nga taipitopito mo 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
})

Takahuri i waenganui i nga tikanga

Takahurihia i waenga i nga tikanga maha me etahi waahi mohio o te data-bs-targetme nga data-bs-togglehuanga. Hei tauira, ka taea e koe te huri i te aratau tautuhi kupuhipa mai i roto i tetahi tohu kua tuwhera i roto i te tikanga. Kia mahara kaore e taea te whakatuwhera i nga tikanga maha i te wa kotahi — ka takahuri noa tenei tikanga i waenga i nga tikanga e rua.

Whakatuwherahia te tikanga tuatahi
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>

Huri hākoritanga

Ka $modal-fade-transformwhakatauhia e te taurangi te ahua o te huringa i .modal-dialogmua i te whakakorikori ahua memeha-i roto, ko te $modal-show-transformtaurangi ka whakatau i te huringa o .modal-dialogte mutunga o te hākoritanga memeha-i roto i te aratau.

Mena kei te pirangi koe hei tauira he hākoritanga topa-mai, ka taea e koe te whakarite $modal-fade-transform: scale(.8).

Tango hākoritanga

Mo nga tauira ka puta noa, kaua e memeha ki te tiro, tangohia te .fadekaraehe mai i to tohu tohu.

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

Te teitei hihiko

Mena ka huri te teitei o te aratau i te wa e tuwhera ana, me waea atu koe myModal.handleUpdate()ki te whakatika i te tuunga o te aratau mena ka puta he pae panuku.

Te urunga

Kia mahara ki te taapiri aria-labelledby="...", tohutoro i te taitara aratau, ki .modal. I tua atu, ka taea e koe te whakaatu i to korero korero mo aria-describedbyrunga i te .modal. Kia mahara kaore koe e hiahia ki te taapiri role="dialog"i te mea kua taapirihia e matou ma te JavaScript.

Te whakauru ataata YouTube

Ko te whakauru i nga riipene YouTube ki roto i nga tikanga ka hiahiatia he JavaScript taapiri kaore i Bootstrap hei aukati aunoa i te purei me etahi atu. Tirohia tenei panui Stack Overflow mo etahi atu korero.

Rahi whiriwhiri

E toru nga rahi o nga tauira, e waatea ana ma nga karaehe whakarereke hei whakanoho ki runga i te .modal-dialog. Ka whana enei rahi ki etahi waahi pakaru hei karo i nga pae panuku whakapae i runga i nga tauranga whaiti.

Rahi Karaehe Modal max-whanui
Iti .modal-sm 300px
Taunoa Karekau 500px
Nui .modal-lg 800px
Nui atu .modal-xl 1140px

Ko ta maatau aratau taunoa kaore he karaehe whakarereke ko te momo momo rahi "waenganui".

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

Modal Mata Katoa

Ko tetahi atu taapiri ko te kowhiringa ki te whakaputa i tetahi aratau e kapi ana i te tauranga tirohanga a te kaiwhakamahi, e waatea ana ma nga karaehe whakarereke ka tuu ki runga i te .modal-dialog.

Karaehe Te waatea
.modal-fullscreen I nga wa katoa
.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

Taurangi

Kua taapirihia ki te v5.2.0

Hei waahanga o te huarahi rerekee CSS a Bootstrap, ka whakamahia e nga modals nga taurangi CSS rohe ki runga .modalme .modal-backdropte whakapai ake i nga whakaritenga-wa-tui. Ko nga uara mo nga taurangi CSS ka whakatauhia ma te Sass, no reira kei te tautoko tonu te whakaritenga Sass.

  --#{$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};
  

Taurangi Sass

$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);

Porowhita

Ko nga tauira mata-katoa whakautu ka hangaia ma te $breakpointsmapi me te kopae i roto 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;
      }
    }
  }
}

Whakamahinga

Ko te mono mono ka huri i to ihirangi huna i runga i te tono, ma nga huanga raraunga, JavaScript ranei. Ka takahia hoki te whanonga panuku taunoa me te whakaputa .modal-backdropi te waahi paatoo mo te whakakore i nga tikanga kua whakaatuhia ina paato i waho o te aratau.

Ma nga huanga raraunga

Takahuri

Whakahohehia he tikanga me te kore e tuhi JavaScript. Whakatakotoria data-bs-toggle="modal"ki runga i te huānga mana whakahaere, penei i te paatene, me te, ki te whai data-bs-target="#foo"ranei href="#foo"i tetahi aratau motuhake hei takahuri.

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

Whakakore

Ka taea te whakakore me te datahuanga i runga i te paatene i roto i te ahua e whakaatuhia ana i raro nei:

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

i runga ranei i tetahi paatene kei waho o te tikanga ma te whakamahi i nga data-bs-targetmea e whakaatuhia ana i raro nei:

<button type="button" class="btn-close" data-bs-dismiss="modal" data-bs-target="#my-modal" aria-label="Close"></button>
Ahakoa e tautokohia ana nga huarahi e rua ki te whakakore i tetahi aratau, kia mahara ko te whakakore i waho o te aratau karekau e taurite ki te tauira korero (tauira) Aratohu Aratohu Kaituhi ARIA . Mahia tenei i runga i to tupono.

Ma te JavaScript

Waihangahia he tikanga me te rarangi kotahi o JavaScript:

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

Kōwhiringa

I te mea ka tukuna nga whiringa ma nga huanga raraunga, JavaScript ranei, ka taea e koe te taapiri i tetahi ingoa whiringa ki data-bs-, penei i te data-bs-animation="{value}". Kia mohio koe ki te whakarereke i te momo keehi o te ingoa whiringa mai i te " CamelCase " ki te " kebab-case " ka tukuna nga whiringa ma nga huanga raraunga. Hei tauira, whakamahia data-bs-custom-class="beautifier"hei utu mo data-bs-customClass="beautifier".

Mai i te Bootstrap 5.2.0, ka tautoko nga waahanga katoa i tetahi huanga raraunga kua rahuitia hei whakamatautaudata-bs-config ka taea te whakanoho i te whirihoranga waahanga ngawari hei aho JSON. Ina he huānga data-bs-config='{"delay":0, "title":123}'me data-bs-title="456"nga huanga, ko te titleuara whakamutunga 456ko nga huanga raraunga motuhake ka takahia nga uara kua hoatu ki runga data-bs-config. I tua atu, ka taea e nga huanga raraunga o mua te whakanoho i nga uara JSON penei i te data-bs-delay='{"show":0,"hide":150}'.

Ingoa Momo Taunoa Whakaahuatanga
backdrop boolean,'static' true Kei roto he huānga tauira-papamuri. Hei statictauira, whakawhāitihia he papamuri e kore e kati i te aratau ina paatohia.
focus boolean true Ka tuu te aro ki te aratau ina arawhiti.
keyboard boolean true Ka kati i te aratau ina pehia te ki mawhiti.

Nga tikanga

Nga tikanga tukutahi me nga whakawhitinga

Ko nga tikanga API katoa he tukutahi ka timata te whakawhiti . Ka hoki mai ano ki te kaikaranga ina timata te whakawhiti engari i mua i te mutunga . I tua atu, ka warewarehia te karanga tikanga mo tetahi waahanga whakawhiti .

Tirohia ta maatau tuhinga JavaScript mo etahi atu korero .

Nga whiringa whakawhiti

Whakahohehia to ihirangi hei aratau. Ka whakaae ki nga whiringa whiriwhiri object.

const myModal = new bootstrap.Modal('#myModal', {
  keyboard: false
})
Tikanga Whakaahuatanga
dispose Ka whakakore i te ahua o te huānga. (Tangohia ai nga raraunga rongoa i te huānga DOM)
getInstance Tikanga pateko e taea ai e koe te tiki i te tauira aratau e hono ana ki tetahi huānga DOM.
getOrCreateInstance Tikanga pateko e taea ai e koe te tiki i te tauira aratau e hono ana ki tetahi huānga DOM, ki te hanga i tetahi mea hou mena kaore i arawhitia.
handleUpdate Whakaritea-a-ringa te tuunga o te aratau mena ka huri te teitei o te aratau i te wa e tuwhera ana (arā, mena ka puta he pae panuku).
hide Ka huna a-ringa i tetahi tikanga. Ka hoki ki te kaiwaea i mua i te hunanga o te tikanga (ara i mua i te hidden.bs.modalputa o te takahanga).
show Ka whakatuwhera a-ringa i te tikanga. Ka hoki ki te kaiwaea i mua i te whakaaturanga o te tikanga (ara i mua i te shown.bs.modalputa o te takahanga). Ano, ka taea e koe te tuku i tetahi huānga DOM hei tohenga ka taea te whiwhi i nga huihuinga aratau (hei relatedTargettaonga). (arā const modalToggle = document.getElementById('toggleMyModal'); myModal.show(modalToggle).
toggle Ka takahuri-a-ringa i te tikanga. Ka hoki ki te kaiwaea i mua i te whakaaturanga, i te hunanga ranei o te aratau (arā, i mua i te puta o shown.bs.modalte hidden.bs.modaltakahanga).

Nga huihuinga

Ko te karaehe aratau a Bootstrap e whakaatu ana i etahi huihuinga mo te hono atu ki nga mahi tikanga. Ko nga huihuinga aratau katoa ka puhia ki te aratau ake (arā, i te <div class="modal">).

Takahanga Whakaahuatanga
hide.bs.modal Ka puhia tonutia tenei takahanga ina hidekua karangahia te aratuka tauira.
hidden.bs.modal Ka pupuhihia tenei takahanga ina mutu te hunanga o te tikanga mai i te kaiwhakamahi (ka tatari kia oti nga whakawhitinga CSS).
hidePrevented.bs.modal Ka pupuhihia tenei takahanga i te wa e whakaatuhia ana te aratau, tona papamuri staticka mahia he paato i waho o te aratau. Ka puhia ano te takahanga ina pehia te ki mawhiti ka whakatauhia te keyboardwhiringa ki false.
show.bs.modal Ka pupuhi tenei takahanga ina ka showkarangahia te aratuka tauira. Mena na te paato i pa, ka waatea te huānga kua paatohia hei relatedTargettaonga mo te huihuinga.
shown.bs.modal Ka pupuhihia tenei takahanga i te wa i kitea ai te ahua ki te kaiwhakamahi (ka tatari kia oti nga whakawhitinga CSS). Mena na te paato i pa, ka waatea te huānga kua paatohia hei relatedTargettaonga mo te huihuinga.
const myModalEl = document.getElementById('myModal')
myModalEl.addEventListener('hidden.bs.modal', event => {
  // do something...
})