简体   繁体   中英

bootstrap 4 plugins - method they are registered in jquery

Reading the bootstrap 4 code (how they register pluging in jquery) I can't understand several lines:

https://github.com/twbs/bootstrap/blob/v4-dev/js/src/tooltip.js

1) Why author add to method Tooltip._jQueryInterface the Constructor property ? What kind of functionalyt they try to provide with that?

  $.fn[NAME] = Tooltip._jQueryInterface // this is clear
  $.fn[NAME].Constructor = Tooltip  // mmmmm ?

2) what is done there (added noConflict method, but how it will be used?):

  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT
    return Tooltip._jQueryInterface
  }

Now I know the answer on question two (wth is $.fn[NAME].noConflict = function () {..} ).

According to https://getbootstrap.com/docs/3.3/javascript/#js-noconflict

This plugins noconflict method can be used such way:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM