Source

JavaScript hmangin a rawn lang ang

jQuery-a siam kan optional JavaScript plugins hmangin Bootstrap chu nunna pe rawh. Plugin tin chungchang te, kan data leh programmatic API option te leh thil dang tam tak zir rawh.

Mimal emaw, khawlkhawm emaw a ni thei

Plugins chu pakhat zel hmangin (Bootstrap’s individual hmangin js/dist/*.js), a nih loh leh vawi khatah hmang vek bootstrap.jsemaw, minified emaw hmangin bootstrap.min.js(a pahnih hian telh loh tur) te pawh a tel thei bawk.

Bundler (Webpack, Rollup...) i hman chuan /js/dist/*.jsUMD ready file i hmang thei bawk.

Innghahna te

Plugin leh CSS component thenkhat chu plugin dang a innghat a ni. Plugin te chu pakhat zel i dah tel a nih chuan docs ah hian heng dependencies te hi check ngei ngei tur a ni. Tin, plugin zawng zawng hi jQuery ah an innghat tih hre bawk ang che (hei hian plugin files hmain jQuery hi a tel tur a ni tihna a ni). jQuery version eng ber nge support tih hriat duh chuan our hi zawt rawh .package.json

Kan dropdowns, popovers leh tooltips te pawh Popper.js ah a innghat bawk .

Data attribute te hi a ni

Bootstrap plugin zawng zawng deuhthaw hi HTML hmang chauhvin data attribute (JavaScript functionality hman dan kan duh ber) hmangin enable leh configure theih a ni. Element pakhatah data attribute set khat chauh hmang ngei ang che (eg, button pakhat atang hian tooltip leh modal i trigger thei lo.)

Mahse, dinhmun thenkhatah chuan he functionality hi tihtawp hi duhthusam a ni thei. Data attribute API disable tur chuan document namespace-a event awm zawng zawng chu hetiang hian unbind vek data-apiang che:

$(document).off('.data-api')

A dang pawhin, plugin bik target tur chuan plugin hming chu namespace atan data-api namespace nen hetiang hian dah mai rawh:

$(document).off('.alert.data-api')
Selector tlanchhuak te

Special selector i hman chuan, entirnan: collapse:Example, chu chu tlanbosan ngei ang che, a chhan chu jQuery kaltlangin an paltlang dawn a ni.

Thil thlengte

Bootstrap hian plugin tam zawkte thiltih danglam bik atan custom event a pe a. A tlangpuiin, hengte hi infinitive leh past participle form-ah an lo kal a - chutah chuan showthilthleng pakhat tan tirh lamah infinitive (ex. ) chu a insiam a, a past participle form (ex. shown) chu thiltih zawh hunah a insiam a ni.

Infinitive event zawng zawng hian preventDefault()functionality an pe vek a. Hei hian action pakhat execution chu a tan hmaa tihtawp theihna a pe a ni. Event handler atanga false rawn thawn let pawhin automatic in a call ang preventDefault().

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})

Programmatic API hmanga siam a ni

Tin, Bootstrap plugin zawng zawng hi JavaScript API hmang chauhvin i hmang thei tur a ni tih kan ring bawk. Public API zawng zawng hi single, chainable method a ni a, collection acted on chu a rawn pe kir vek a ni.

$('.btn.danger').button('toggle').addClass('fat')

Method zawng zawng hian optional options object, method bik target tu string emaw, engmah (default behavior hmanga plugin initiate tu) emaw an pawm tur a ni:

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately

Plugin tin hian an raw constructor chu Constructorproperty pakhatah an expose bawk: $.fn.popover.Constructor. Plugin instance bik i hmuh duh chuan element atanga direct-in la chhuak rawh: $('[rel="popover"]').data('popover').

Asynchronous function leh inthlak danglamna te

Programmatic API method zawng zawng hi asynchronous a ni a , transition a tan veleh a tawp hmain caller hnenah a kir leh thin .

Transition zawh veleh action execute tur chuan a inmil event chu i ngaithla thei ang.

$('#myCollapse').on('shown.bs.collapse', function (e) {
  // Action to execute once the collapsible area is expanded
})

Chu bakah transitioning component a method call chu ngaihthah a ni ang .

$('#myCarousel').on('slid.bs.carousel', function (e) {
  $('#myCarousel').carousel('2') // Will slide to the slide 2 as soon as the transition to slide 1 is finished
})

$('#myCarousel').carousel('1') // Will start sliding to the slide 1 and returns to the caller
$('#myCarousel').carousel('2') // !! Will be ignored, as the transition to the slide 1 is not finished !!

Settings hmasa ber a ni

Plugin pakhat tana default settings chu plugin Constructor.Defaultobject chu siam danglamin i thlak thei ang:

$.fn.modal.Constructor.Default.keyboard = false // changes default for the modal plugin's `keyboard` option to false

Inhnialna a awm lo

A chang chuan Bootstrap plugins te hi UI framework dang nen hman a ngai thin. Hetiang dinhmunah hian namespace collision a awm fo thin. Chutiang a nih chuan i .noConflictvalue revert duh plugin chu i call thei ang.

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality

Version number te pawh a awm

Bootstrap-a jQuery plugin pakhat zel version chu VERSIONplugin constructor property hmangin a lut thei a ni. Entirnan, tooltip plugin atan chuan:

$.fn.tooltip.Constructor.VERSION // => "4.1.3"

JavaScript tihtawp a nih chuan special fallback a awm lo

Bootstrap-a plugins te hi JavaScript tihtawp a nih chuan a bik takin grace takin an tla leh lo. Hetiang a nih avang hian user experience i ngaih pawimawh a nih chuan, i user-te <noscript>hnena thil awmdan (leh JavaScript re-enable dan tur) hrilhfiah nan hmang la, leh/ emaw, nangmah ngeiin i custom fallback te pawh add rawh.

Third-party library te pawh a awm bawk

Bootstrap hian official takin third-party JavaScript library Prototype emaw jQuery UI ang chi a support lo. Despite .noConflictleh namespaced events, compatibility problem a awm thei a, chu chu nangmah ngeiin i siam that a ngai a ni.

Util

Bootstrap-a JavaScript file zawng zawng hi a innghat a, util.jsJavaScript file dangte nen a dah tel a ngai bawk. Compiled (or minified) i hmang a nih chuan bootstrap.jshei hi dah tel a ngai lo—a awm tawh.

util.jsutility function leh transitionEndevent hrang hrang atana basic helper bakah CSS transition emulator a awm bawk. Plugin dangte chuan CSS transition support a awm leh awm loh enfiah nan leh hanging transition man nan an hmang thin.