如何使用带有CI的jquery设置href模态

   <script>
        $(document).on("click", ".btn", function(){
            var dataID = $(this).data('id');
            var link = '<?php echo base_url()."admin/employees/deleteEmpOffice/";?>' + dataID;
            document.getElementById("deleteEmp").setAttribute("href",link);
        });
    </script>

This is my jquery

                            <tbody>                                 
                                <?php  if (is_array($empOffice) && count($empOffice)) : foreach ($empOffice as $row ) : ?>
                            <tr>
                                <td> <?php  echo $row->employee_id;?></td>
                                <td> <?php  echo $row->employee_first_name; ?></td>
                                <td> <?php  echo $row->employee_last_name; ?></td>
                                <td> <?php  echo $row->employee_position; ?></td>
                                <td> <?php  echo $row->employee_address; ?></td>
                                <td> <?php  echo $row->employee_mobile; ?></td>
                                <td class="center">
                                <a class="btn btn-info" href="#">
                                    <i class="halflings-icon white edit"></i>  
                                </a>
                                <a class="btn btn-danger btn-setting"  href="<?php echo base_url(); ?>admin/vwDeleteModal" data-id="<?php echo  $row->employee_id;?>" >
                                    <i class="halflings-icon white trash"></i> 
                                </a>
                            </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php endif; ?>
                        </tbody>

this is the html part with view and delete option where I set the data-id and is link to vwDeleteModal

<div class="modal hide fade" id="myModal">
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3>Please Confirm</h3>
</div>
<div class="modal-body">
    <p>Are you sure?</p>
</div>
<div class="modal-footer">

    <a href="#" class="btn" data-dismiss="modal">Close</a>
    <a id="deleteEmp" class="btn btn-primary">OK</a>
</div>

vwDeleteModal is loaded using <?php echo $this->load->view();?>

Now when I click Ok button in vwDeleteModal, the segment(4) in the url which supposedly the employee_id is declared undefined and i cant delete the employee please can someone help me?!!

To get the value of data-id try:

var dataID = $(this).attr('data-id');

instead of

var dataID = $(this).data('id');

EDIT:

Maybe this solves your problem:

 <a class="btn btn-danger btn-setting"  href="<?php echo base_url(); ?>admin/vwDeleteModal/<?php echo  $row->employee_id;?>">
      <i class="halflings-icon white trash"></i> 
</a>

and

<a id="deleteEmp" class="btn btn-primary" data-id="<?php echo $this->uri->segment(3); ?>">OK</a>
<script>
    $(document).on("click", ".btn", function(){
        var dataID = $(this).data('id');
        var href = $(this).attr('href');
        $('#deleteEmp').attr('href',href);
    });
</script>
<a class="btn btn-danger btn-setting"  href="<?php echo base_url()."admin/employees/deleteEmpOffice/"."$row->employee_id";?>" data-id="<?php echo  $row->employee_id;?>">
<i class="halflings-icon white trash"></i> 
</a>

i solve it guys i just copy the link from a class ans set it to my modal. Thank you for your time