简体   繁体   English

ui-select inside的可点击区域是10px引导模态

[英]clickable area of ui-select inside is 10px a bootstrap modal

I have a bootstrap modal and, inside it, I have a ui-select for tagging. 我有一个bootstrap模式,在其中,我有一个用于标记的ui-select。 Here's my example: 这是我的例子:

<div class="modal modal-invite">
  <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">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <ui-select multiple tagging tagging-label="" ng-model="email_list" theme="bootstrap" ng-disabled="disabled" on-select="" on-remove=""  title="Insert your friends email here." >
          <ui-select-match placeholder="Your friends email here...">{{$item}}</ui-select-match>
          <ui-select-choices repeat="email in email_list | filter:$select.search">
            {{email}}
          </ui-select-choices>
        </ui-select>
      </div>
      <div class="modal-footer">
        <button class="btn btn-success">Invite</button>
      </div>
    </div>
  </div>
</div>

My problem is: When I open the modal with $('modal-invite').modal('show') , the size of the placeholder (and the clickable area) is 10 pixel, like this: 我的问题是:当我用$('modal-invite').modal('show')打开模态时,占位符(和可点击区域)的大小是10像素,如下所示:

10px大小的占位符

Google Chrome检查员

After clicking on it, it gets the correct width. 点击它后,它获得正确的宽度。
How can I make ui-select refresh it's size when the modal opens? 当模态打开时,如何使ui-select刷新它的大小?

Finally I solved checking the ui-select sources. 最后我解决了检查ui-select源的问题。
It seems that ui-select recalculates the input size with a $watch on the parent width. 似乎ui-select使用父宽度上的$watch重新计算输入大小。

So, in order to refresh it, I did like this: 所以,为了刷新它,我确实喜欢这样:

$('.modal-invite').modal('show');
$scope.$apply();

I had simular problem. 我有类似的问题。

I know altering a source file is not good practice, and it would be better to somehow target it from my own code - but for now I fixed it by commenting out a line in the source code that sets the input field to 10px when its rendering the tags. 我知道改变一个源文件不是一个好习惯,最好以某种方式从我自己的代码中定位它 - 但是现在我通过在源代码中注释掉一行来修复它,该行在渲染时将输入字段设置为10px标签。

In line 831 in the source select.js file, comment out: ctrl.searchInput.css('width', '10px'); 在source select.js文件的第831行中,注释掉: ctrl.searchInput.css('width', '10px');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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