精华内容
下载资源
问答
  • Modal

    2020-04-15 21:02:23
    Modal Use Bootstrap’s JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content. ads via Carbon Adobe Creative Cloud for Teams starting at $...

    Modal

    Use Bootstrap’s JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
    ads via Carbon
    Adobe Creative Cloud for Teams starting at $33.99 per month.
    ads via Carbon
    How it works

    Before getting started with Bootstrap’s modal component, be sure to read the following as our menu options have recently changed.

    Modals are built with HTML, CSS, and JavaScript. They’re positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead.
    Clicking on the modal “backdrop” will automatically close the modal.
    Bootstrap only supports one modal window at a time. Nested modals aren’t supported as we believe them to be poor user experiences.
    Modals use position: fixed, which can sometimes be a bit particular about its rendering. Whenever possible, place your modal HTML in a top-level position to avoid potential interference from other elements. You’ll likely run into issues when nesting a .modal within another fixed element.
    Once again, due to position: fixed, there are some caveats with using modals on mobile devices. See our browser support docs for details.
    Due to how HTML5 defines its semantics, the autofocus HTML attribute has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript:
    

    $(’#myModal’).on(‘shown.bs.modal’, function () {
    $(’#myInput’).trigger(‘focus’)
    })

    The animation effect of this component is dependent on the prefers-reduced-motion media query. See the reduced motion section of our accessibility documentation.

    Keep reading for demos and usage guidelines.
    Examples
    Modal components

    Below is a static modal example (meaning its position and display have been overridden). Included are the modal header, modal body (required for padding), and modal footer (optional). We ask that you include modal headers with dismiss actions whenever possible, or provide another explicit dismiss action.
    Modal title

    Modal body text goes here.

    Live demo

    Toggle a working modal demo by clicking the button below. It will slide down and fade in from the top of the page.

    Launch demo modal

    Static backdrop

    When backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try it.

    Launch static backdrop modal

    Scrolling long content

    When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean.

    Launch demo modal

    You can also create a scrollable modal that allows scroll the modal body by adding .modal-dialog-scrollable to .modal-dialog.

    Launch demo modal

    Vertically centered

    Add .modal-dialog-centered to .modal-dialog to vertically center the modal.

    Launch demo modal

    Tooltips and popovers

    Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.

    Using the grid

    Utilize the Bootstrap grid system within a modal by nesting .container-fluid within the .modal-body. Then, use the normal grid system classes as you would anywhere else.

    Varying modal content

    Have a bunch of buttons that all trigger the same modal with slightly different contents? Use event.relatedTarget and HTML data-* attributes (possibly via jQuery) to vary the contents of the modal depending on which button was clicked.

    Below is a live demo followed by example HTML and JavaScript. For more information, read the modal events docs for details on relatedTarget.

    Open modal for @mdo
    Open modal for @fat
    Open modal for @getbootstrap

    $(’#exampleModal’).on(‘show.bs.modal’, function (event) {
    var button = $(event.relatedTarget) // Button that triggered the modal
    var recipient = button.data(‘whatever’) // Extract info from data-* attributes
    // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
    // Update the modal’s content. We’ll use jQuery here, but you could use a data binding library or other methods instead.
    var modal = $(this)
    modal.find(’.modal-title’).text(‘New message to ’ + recipient)
    modal.find(’.modal-body input’).val(recipient)
    })

    Change animation

    The $modal-fade-transform variable determines the transform state of .modal-dialog before the modal fade-in animation, the $modal-show-transform variable determines the transform of .modal-dialog at the end of the modal fade-in animation.

    If you want for example a zoom-in animation, you can set $modal-fade-transform: scale(.8).
    Remove animation

    For modals that simply appear rather than fade in to view, remove the .fade class from your modal markup.

    Dynamic heights

    If the height of a modal changes while it is open, you should call $(’#myModal’).modal(‘handleUpdate’) to readjust the modal’s position in case a scrollbar appears.
    Accessibility

    Be sure to add role=“dialog” and aria-labelledby="…", referencing the modal title, to .modal, and role=“document” to the .modal-dialog itself. Additionally, you may give a description of your modal dialog with aria-describedby on .modal.
    Embedding YouTube videos

    Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. See this helpful Stack Overflow post for more information.
    Optional sizes

    Modals have three optional sizes, available via modifier classes to be placed on a .modal-dialog. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports.
    Size Class Modal max-width
    Small .modal-sm 300px
    Default None 500px
    Large .modal-lg 800px
    Extra large .modal-xl 1140px

    Our default modal without modifier class constitutes the “medium” size modal.

    Extra large modal

    Large modal

    Small modal

    Usage

    The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open to the to override default scrolling behavior and generates a .modal-backdrop to provide a click area for dismissing shown modals when clicking outside the modal.
    Via data attributes

    Activate a modal without writing JavaScript. Set data-toggle=“modal” on a controller element, like a button, along with a data-target="#foo" or href="#foo" to target a specific modal to toggle.

    Launch modal

    Via JavaScript

    Call a modal with id myModal with a single line of JavaScript:

    $(’#myModal’).modal(options)

    Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-backdrop="".
    Name Type Default Description
    backdrop boolean or the string ‘static’ true Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn’t close the modal on click or on escape key press.
    keyboard boolean true Closes the modal when escape key is pressed
    focus boolean true Puts the focus on the modal when initialized.
    show boolean true Shows the modal when initialized.
    Methods
    Asynchronous methods and transitions

    All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.

    See our JavaScript documentation for more information.
    .modal(options)

    Activates your content as a modal. Accepts an optional options object.

    $(’#myModal’).modal({
    keyboard: false
    })

    .modal(‘toggle’)

    Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the shown.bs.modal or hidden.bs.modal event occurs).

    $(’#myModal’).modal(‘toggle’)

    .modal(‘show’)

    Manually opens a modal. Returns to the caller before the modal has actually been shown (i.e. before the shown.bs.modal event occurs).

    $(’#myModal’).modal(‘show’)

    .modal(‘hide’)

    Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the hidden.bs.modal event occurs).

    $(’#myModal’).modal(‘hide’)

    .modal(‘handleUpdate’)

    Manually readjust the modal’s position if the height of a modal changes while it is open (i.e. in case a scrollbar appears).

    $(’#myModal’).modal(‘handleUpdate’)

    .modal(‘dispose’)

    Destroys an element’s modal.
    Events

    Bootstrap’s modal class exposes a few events for hooking into modal functionality. All modal events are fired at the modal itself (i.e. at the

    $(’#myModal’).on(‘hidden.bs.modal’, function (e) {
    // do something…
    })

    展开全文
  • modal

    2018-05-31 14:13:00
    通过这种方式绑定数据$("#modalTarget").data("target", paras); 然后取出数据, data: JSON.stringify($("#modalTarget").data("target")), <!-- Modal Update Failed...div class="modal fade" id="UpdateM...

     通过这种方式绑定数据 $("#modalTarget").data("target", paras);

    然后取出数据,   data: JSON.stringify($("#modalTarget").data("target")),

    <!-- Modal Update Failed-->
        <div class="modal fade" id="UpdateModalFailed">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-body">
                        <p id="modelFailedText" class="text-center" style="margin: 30px 0px;">&nbsp;</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal"><%= GetResourceValue("CP_PointAssignment_Cancel") %></button>
                    </div>
                </div>
            </div>
        </div>
        <!-- Modal Confirm-->
        <div class="modal fade" id="modalConfirmAssignement">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">×</span></button>
                        <h2><%= GetResourceValue("CP_PointAssignment_ConfirmAssignment") %></h2>
                    </div>
                    <div class="modal-body">
                        <table class="table text-center">
                            <thead>
                                <tr>
                                    <th><%= GetResourceValue("CP_PointAssignment_TotalAssigned") %></th>
                                    <th><%= GetResourceValue("CP_PointAssignment_RemainingPoints") %></th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        <em>
                                            <b class="green">0</b>
                                        </em>
                                    </td>
                                    <td>
                                        <b>0</b>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <div class="col-sm-6 text-center">
                            <button type="button" id="btnAssignmentAccept" data-loading-text="<%= GetResourceValue("CP_PointAssignment_Processing") %>" class="bt-rounded bt-green w-200"><%= GetResourceValue("CP_PointAssignment_Accept") %></button>
                        </div>
                        <div class="col-sm-6 text-center">
                            <button type="button" class="bt-rounded bt-gray w-200" data-dismiss="modal" aria-label="Close"><%= GetResourceValue("CP_PointAssignment_Cancel") %></button>
                        </div>
                        <input type="hidden" id="modalTarget" />
                    </div>
                </div>
            </div>
        </div>
        <!-- Modal Assign Success-->
        <div class="modal fade " id="modalConfirmated">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content border-top-blue">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">×</span></button>
                    </div>
                    <div class="modal-body">
                        <div class="w-100 margin-top-20  message">
                            <div class="inner-message ">
                                <i class="ico ico-mark-bold"></i>
                                <p>
                                    <em id="emTitle"><%= GetResourceValue("CP_PointAssignment_AssignSucceed") %></em>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

     

    data-dismiss

    https://stackoverflow.com/questions/34627271/understanding-how-data-dismiss-attribute-works-in-bootstrap

    The hiding functionality is implemented in the modal.js in this way.

    this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))

    Basically it's just finding the elements that have the attribute of data-dismiss and the value of modal. Upon click it will hide these elements.

     

    转载于:https://www.cnblogs.com/chucklu/p/9116425.html

    展开全文
  • <p>Everything works, but when component A triggers modal B, that modal is being rendered inside the first modal. Check screenshot: <p><img alt="screenshot from 2017-12-26 11-15-42" src=...
  • 主要介绍了扩展bootstrap的modal模态框-动态添加modal框-弹出多个modal框,需要的朋友可以参考下
  • modal in front of a modal

    2021-01-10 11:03:30
    In my app, i need to open a new modal in front of an existing modal, but i couldn't make it work...</p><p>该提问来源于开源项目:react-native-modal/react-native-modal</p></div>
  • modal dismiss

    2020-12-26 03:55:04
    m trying to close the modal when clicking outside it. But the modal is only hidden, and the code still exist. And if i open it again, it will be duplicated. I've tried your tip like: <code>...
  • <div><p>There is some problem when calling <code>Modal.hide()</code> in the event-listener at least for <code>shown.bs.modal</code> and the Modal is already hidden. <pre><code>JavaScript var ...
  • ng2-bs3-modal.ts:19 ORIGINAL EXCEPTION: TypeError: this.$modal.appendTo(...).modal is not a functionBrowserDomAdapter.logError @ ng2-bs3-modal.ts:19ExceptionHandler.call @ ng2-bs3-modal.ts:19...
  • <div><h2>Title line template: [Title]: The second Modal can not focus input when opening the second modal in the first Modal <h2>What package(s) are you using? <ul><li> [x] carbon-components-react@...
  • bootstrap modal

    2018-12-19 10:11:11
    1无法弹出多个modal 解决方法,将每一个modal用一组div标签包裹 2点击空白不关闭设置 backdrop:static时,空白处不关闭. keyboard:false时,esc键盘不关闭. $(modalid).modal({backdrop: 'static', keyboard: ...

    1无法弹出多个modal

    解决方法,将每一个modal用一组div标签包裹

    2点击空白不关闭设置

    backdrop:static时,空白处不关闭.

    keyboard:false时,esc键盘不关闭.

    $(modalid).modal({backdrop: 'static', keyboard: false});

    <div class="modal fade" tabindex="0" role="dialog" id="myModal" data-backdrop="static">

    3解决弹出多个modal时下方modal无法滚动的问题

    //解决弹出多个modal时,无法滚动的问题
    function showModalRoll() {
        // An highlighted block
         $('#最上方modal的id').on("hidden.bs.modal",function(){
            $(document.body).addClass("modal-open");
        });
    
    }

    在页面一加载函数中调用

    4解决modal中,不能自动聚焦到第一个input框中的问题

    function addSpecialContentmodal() {
       //设置点击空白处不关闭modal
        //$("#specialContentModal").modal({backdrop: 'static', keyboard: false});
        $("#btn_addPerson").show();
        $("#btn_update").hide();
        $("#btn_save").show();
    //打开modal
        $("#specialContentModal").modal("show");
    //注册modal打开事件,让其自动聚焦到第一个input框
        $('#specialContentModal').on('shown.bs.modal', function () {
            $("#specialName").focus();
        })
    }

     

    展开全文
  • <div><p>Hi, by opening modal I am getting: <pre><code> TypeError: this.$modal.modal is not a function at ModalInstance.show (modal-instance.ts:49) </code></pre> <p>what could it be?</p><p>该提问来源...
  • ionic Modal

    2019-10-03 11:14:50
    在ionic中,modal也是添加控制器写服务的~ 在modal.html页面中增加控制器:ng-controller="aboutCtrl"记住要给这个添加控制器。头部使其关闭按钮,只需要使用ng-click = "hide()" 在app.js中初始化modal:$...

    在ionic中,modal也是添加控制器写服务的~

    在modal.html页面中增加控制器:ng-controller="aboutCtrl"
    记住要给这个添加控制器。
    头部使其关闭按钮,只需要使用ng-click = "hide()"

    在app.js中初始化modal:
    $rootScope.aboutModal = modalSvc.createModal('templates/about.html');


    在控制器下要使用:
    $scope.openAboutModal = function(){
    $rootScope.aboutModal.show();
    }

     

    modalSvc.js:
    记住在最后要返回。

    /**
     *
     *
     * 初始化:
     *      var $rootScope.oneModal = modalSvc.createModal(templateUrl);
     *
     *
     * 指定控制器
     *      <ion-view class="modal" ng-controller="loginCtrl">
     *
     *
     * 打开modal并传递数据
     *      oneModal.show(params);
     *      通过参数params可以向modal中传递数据
     *      <span>{{params.title}}</span>
     *
     *
     * 通过完成事件获得结果
     *      function onModalComplete(result) {
     *      }
     *      oneModal.show(params).then(onModalComplete);
     *      其中result 就是modal关闭时的结果,也是hide函数传回的值: hide(result)
     *      如果通过其他方式关闭modal,也会调用onModalComplete,但result为undefined
     *
     *
     * 关闭modal
     *      oneModal.hide(result)
     *      result作为modal的结果,传回调用者
     *
     *
     * 在模板中关闭modal
     *      <button ng-click="hide(true)">OK</button>
     *      <button ng-click="hide()">Cancel</button>
     *
     *
     * 指定每次modal打开时要执行的代码
     *      oneModal.scope.events.onShow = function ($scope) {}
     *
     *
     * 指定每次modal关闭时要执行的代码
     *      oneModal.scope.events.onHide = function ($scope) {}
     *
     */
    angular.module('modalSvc', ['ionic']).factory('modalSvc', [
      '$q', '$rootScope', '$ionicModal'
      , function ($q, $rootScope, $ionicModal) {
        function createModal(templateURL) {
          var modalService = {
            scope: $rootScope.$new(),
            modalWindow: null,
    
            show: function (params) {
              this.scope.q = $q.defer();
              this.scope.params = params || {};
              if (this.modalWindow) {
                var scope = this.scope;
                this.modalWindow.show().then(function () {
                  if (scope.events.onShow) {
                    scope.events.onShow(scope);
                  }
                });
              }
              return this.scope.q.promise;
            },
    
            hide: function (result) {
              if (this.modalWindow) {
                var scope = this.scope;
                this.modalWindow.hide().then(function () {
                  if (scope.events.onHide) {
                    scope.events.onHide(scope);
                  }
                });
              }
              if (this.scope.q) {
                this.scope.q.resolve(result);
                this.scope.q = undefined;
              }
            }
          };
    
          modalService.scope.events = {
            // onShow
            // onHide
          };
    
          modalService.scope.hide = function (result) {
            modalService.hide(result);
          };
    
          $ionicModal.fromTemplateUrl(templateURL, function (modal) {
            modalService.modalWindow = modal;
          }, {
            scope: modalService.scope,
            animation: 'slide-in-up'
          });
    
          return modalService;
        }
    
        return {createModal: createModal};
      }
    ]);

     

    转载于:https://www.cnblogs.com/maoyazhi/p/4462845.html

    展开全文
  • <div><ul><li>Adds expand/compress modes to the modal in hydrator++</li><li>After talking to modified the modal to be cdap modal instead of the Hydrator modal (styling)</li></ul>该提问来源于...
  • 安装和下载:# NPM$ npm install @melmacaluso/vue-modal --save使用:只需将其导入所需的vue组件中,如下所示:import Modal from "@melmacaluso/vue-modal";Props:Props类型评论btnText串模态按钮的文本...
  • 如两个modal,在第一个modal上又显示第二个modal。 默认情况下,两个modal可以同时操作。 但如果想打开第二个modal的时候,禁止操作第一个modal上的内容,可以通过再创建一个新的modal,作为中间层。 这个中间层modal...
  • Modal UX inconsistency

    2020-12-26 13:05:51
    <p>See the <a href="https://projects.invisionapp.com/dsm/silver-stripe/silver-stripe/asset/components/5bdf8561a927a20011a0bb77">Styleguide</a> for modal dimensions and designs. <p>Some quick ...
  • iView-UI:使用Modal调用Modal

    千次阅读 2019-10-23 20:03:35
    iView的Modal真的非常不友好,用起来总感觉this.$Modal多次调用的话采用的是引用的方式,结果导致后面的Modal的属性会覆盖前面的Modal,而前面的Modal一关闭导致写在onOK函数里面的Modal也一并关闭了。 解决方案 我...
  • The modal works when I add a button in the modal. <p><strong>Hosting Model (is this issue happening with a certain hosting model?): - Blazor Server</p><p>该提问来源于开源项目:Blazored/Modal...
  • modal

    2018-09-02 22:09:00
    modal框 创建modal款的基本“框架”: 1 <body> 2 <!--1、触发模态框的按钮--> 3 <button class="btn btn-info" data-toggle="modal" data-target="#myModal">注册</button> 4 ....

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 31,267
精华内容 12,506
关键字:

modal