doulilou8560 2018-08-02 04:57
浏览 60

Bootstrap模式未显示在所选选项中

I Have a bootstrap form I'm trying to create and having problems with opening a model from a selected drop-down menu option.

I can get it to open with the button link next to it but it won't work in the drop-down menu. The other thing that's puzzling is it works in a jsfiddle but not on my site.

Any clues would be appreciated

JSFiddle

Here is my add_job.php(part file) can include rest if required

        <div class="panel-body">
         <div class="col-md-12 col-md-offset-1">
          <div class="row">
          <div class="help-block with-errors"></div>
            <div class="col-md-4">
              <div class="form-group">
                <label for="form_contractor">Select Contractor *</label>
                    <select class="selectpicker form-control" data-live-search="true" id="contractor" name="contractor" required="required" data-error="Contractor is required.">
                            <option value="">Please select contractor *</option>
                            <option value="addnewcon">Add new Contractor</option>
                            <?php  foreach ($all_contractors as $con): ?>
                              <option value="<?php echo $con['ID'] ?>">
                                <?php echo $con['Name'] ?>
                              </option>
                             <?php endforeach; ?>
                    </select>
                <div class="help-block with-errors"></div>
              </div>
            </div>

      <!-- Modal -->
<div id="addnewcon" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <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>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Exercitationem omnis aliquid voluptatibus, distinctio soluta eligendi officiis voluptatem necessitatibus magnam illum.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save</button>
      </div>
    </div>
  </div>
</div>

            <div class="col-md-1">
              <div class="form-group">
                <label for="form_addnewcon"></label><BR><BR>
                <button type="button" data-toggle="modal" data-target="#addnewcon">Add new</button>
                <div class="help-block with-errors"></div>

And here is the section of code from my functions.js

$("#contractor").change(function () {        
if($(this).val() == 'addnewcon'){
    $('#addnewcon').modal({show: true});
}});

EDIT

Updated JS code

So after working out the debug in my code, I can now get it to work in IE, Firefox but still not working in chrome

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
    • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
    • ¥15 运动想象脑电信号数据集.vhdr
    • ¥15 三因素重复测量数据R语句编写,不存在交互作用
    • ¥15 微信会员卡等级和折扣规则
    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了