【问题标题】:bootstrap model is not working引导模型不起作用
【发布时间】:2017-06-18 02:44:20
【问题描述】:

我是 bootstrap 的新手现在我正在使用 bootsrap 和 codeigniter 设计一个网站...这里我使用的是模态。当我单击模态按钮时 data-toggle="modal" 没有显示模态表单。任何人都可以解决这个问题。提前致谢。

这是我的代码

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Meta tag for IE -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Helen Flaghrity Charitable Society</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link href="<?php echo base_url("assets/css/bootstrap.css");?>" rel="stylesheet">
<link href="<?php echo base_url("assets/css/admin/admin.css");?>" rel="stylesheet">
<link href="<?php echo base_url("assets/css/font-awesome.min.css");?>" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css"/>
<style>
</style>
</head>
<body>
<div class="container-fluid">
<div class="row" style="position: relative;top:-20px;">
    <div class="col-sm-2" style="background-color: #000;height:700px">
        <ul class="menu sidebar_box" >
            <li><a href="<?php echo base_url();?>Admin_Ctrl/profile">Messages</a></li>
            <li><a href="<?php echo base_url();?>Admin_Ctrl/projects">Add Projects</a></li>
            <li><a href="<?php echo base_url();?>Admin_Ctrl/news">Add News</a></li>
            <li><a href="<?php echo base_url();?>Admin_Ctrl/images">Images</a></li>
            <li><a href="<?php echo base_url();?>Admin_Ctrl/contact">Contact</a></li>
        </ul>
      </div>
<div class="col-sm-10">
<br />
<button type="button" class="btn btn-info btn-sm"  data-toggle="modal" data-target="#addProjects">Add Projects</button>
<br />
<br />
<table id="projects" class="table table-striped table-bordered" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Title</th>
                <th>Images</th>
                <th>Messages</th>
                <th>Date</th>
                <th>Delete</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
        <tfoot>
            <tr>
                <th>Title</th>
                <th>Images</th>
                <th>Messages</th>
                <th>Date</th>
                <th>Delete</th>
            </tr>
        </tfoot>
</table>
</div>
</div>
</div>
<div id="addProjects" class="modal fade"  role="dialog">
    <div class="modal-dialog">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Message</h4>
        </div>
        <div class="modal-body">
          <form enctype="multipart/form-data" action="do_upload" id="submit" method="post">
               <div class="form-group">
                  <label for="projecttitle">Project Title</label>
                  <input type="text" class="form-control" name="projecttitle" id="imagetitle" placeholder="Enter Project Title" required="required">
               </div>
              <div class="control-group form-group">
                   <div class="controls">
                    <label>Upload Photo:</label>
                    <input name="file" type="file" id="file" required>
                    <p class="help-block"></p>
               </div>
               </div>
              <div class="form-group">
                  <label for="projectmessage">Project Message</label>
                  <textarea class="form-control" rows="8" name="projectmessage" id="projectmessage"></textarea> 
              </div>

               <button type="submit" class="btn btn-primary" id="submit">Submit</button>
        </form>
      </div>
      </div>
    </div>
</div>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

</body>
</html>

【问题讨论】:

    标签: bootstrap-modal


    【解决方案1】:

    问题是您在 jquery.min.js 之前包含 bootstrap.min.js。
    你必须在 bootstrap.min.js 之前声明 jquery.min.js

    这是工作代码:

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Meta tag for IE -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>Helen Flaghrity Charitable Society</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css"/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" />
    <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
    </head>
    <body>
    <div class="container-fluid">
    <div class="row" style="position: relative;top:-20px;">
        <div class="col-sm-2" style="background-color: #000;height:700px">
            <ul class="menu sidebar_box" >
                <li><a href="">Messages</a></li>
                <li><a href="">Add Projects</a></li>
                <li><a href="">Add News</a></li>
                <li><a href="">Admin_Ctrl/images>Images</a></li>
                <li><a href="">Admin_Ctrl/contact>Contact</a></li>
            </ul>
          </div>
    <div class="col-sm-10">
    <br />
    <button type="button" class="btn btn-info btn-sm"  data-toggle="modal" data-target="#addProjects">Add Projects</button>
    <br />
    <br />
    <table id="projects" class="table table-striped table-bordered" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Title</th>
                    <th>Images</th>
                    <th>Messages</th>
                    <th>Date</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
            <tfoot>
                <tr>
                    <th>Title</th>
                    <th>Images</th>
                    <th>Messages</th>
                    <th>Date</th>
                    <th>Delete</th>
                </tr>
            </tfoot>
    </table>
    </div>
    </div>
    </div>
    <div id="addProjects" class="modal fade"  role="dialog">
        <div class="modal-dialog">
          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
    
              <h4 class="modal-title">Message</h4>
            </div>
            <div class="modal-body">
              <form enctype="multipart/form-data" action="do_upload" id="submit" method="post">
                   <div class="form-group">
    
                      <input type="text" class="form-control" name="projecttitle" id="imagetitle" placeholder="Enter Project Title" required="required">
                   </div>
                  <div class="control-group form-group">
                       <div class="controls">
                        <label>Upload Photo:</label>
                        <input name="file" type="file" id="file" required>
                        <p class="help-block"></p>
                   </div>
                   </div>
                  <div class="form-group">
                      <label for="projectmessage">Project Message</label>
                      <textarea class="form-control" rows="8" name="projectmessage" id="projectmessage"></textarea> 
                  </div>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                   <button type="submit" class="btn btn-primary" id="sub">Submit</button>
            </form>
          </div>
          </div>
        </div>
    </div>
    
    
    
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      • 1970-01-01
      相关资源
      最近更新 更多