我想在codeigniter的控制器中使用调用函数来调用bootstrap模态

时间:2015-09-23 12:56:53

标签: codeigniter bootstrap-modal

这里我使用codeigniter函数调用bootstrap模式的视图。但它没有正常工作。这是代码:

在codeigniter中:

function alert_breaktime()
{
   $this->load->view('break_alert');
}

break_alert.php:

<div class="modal-dialog">
    <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button> <h3 class="modal-title" style="color: red;font-weight: bold;">Message Alert !</h3>
            </div>
            <?php //$attributes = array('class' => 'bs-example form-horizontal'); echo form_open(base_url().'activity/add',$attributes); ?>
            <div class="modal-body">
                <div class="message" style="font-size: x-large;">
                    Hello, <?php
                    $user_id = $this->tank_auth->get_user_id();
                    $names = $this->user_profile->get_profile_details($user_id,'fullname') ? $this->user_profile->get_profile_details($user_id,'fullname') : $this->tank_auth->get_username();

                    echo $names ?> <br>
                    Please do not forget to <b>Break Out..!!</b>

                </div>
        <div class="modal-footer">
                    <a href="#" class="btn btn-default" data-dismiss="modal"><?=lang('close')?></a> 

        </div>
            </div>

    </div>
</div>

1 个答案:

答案 0 :(得分:0)

由于您已告知您的代码无效,我假设您可能没有正确调用引导程序库。

我已将所有jquery和bootstrap css文件包含在您的代码中,并且它在我的计算机中运行。

以下是我编辑的代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">

  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" 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>

        </div>
        <div class="modal-body">
          <div class="message" style="font-size: x-large;">
                    Hello, <?php
                    $user_id = $this->tank_auth->get_user_id();
                    $names = $this->user_profile->get_profile_details($user_id,'fullname') ? $this->user_profile->get_profile_details($user_id,'fullname') : $this->tank_auth->get_username();

                    echo $names ?> <br>
                    Please do not forget to <b>Break Out..!!</b>

                </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>

    </div>
  </div>

</div>

</body>
</html>

我希望这段代码可以帮到你.. 如果该代码存在任何问题,请告诉我。