0

Here I am calling view of bootstrap modal using codeigniter function. But its not working proper. Here is code:

In 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>
Viral Bhoot
  • 357
  • 3
  • 17
  • The modal won't load in that way. Have a look at this: http://stackoverflow.com/questions/14971766/load-content-with-ajax-in-bootstrap-modal – Andre Garcia Sep 23 '15 at 17:08
  • First of where are you ajax and bootstrap,js and css etc stored –  Sep 24 '15 at 12:29
  • I'm pretty sure you also want to assign your variables in the controller and pass them in to the view – danneth Sep 24 '15 at 13:51

1 Answers1

0

Since you have told your code is not working I assume you may have not call the bootstrap libraries properly.

I have included all jquery and bootstrap css files to your code and it working in my computer.

below is your code edited by me:

<!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>

I hope this code would help you.. let me know if there is any problem with that code.