Use modal bootstrap as delete prompt in codeigniter? -
i have problem view or prompt delete text confirmation, can use modal in bootstrap in prompt delete?
i try , can delete in first "id" not in specific id , don't know make specific id.
here view:
<div class="table-responsive"> <?php if(sizeof($query) < 1) : ?> no record in database. <?php else : ?> <table class="table table-hover"> <thead> <tr> <th>id</th> <th>title</th> <th>content</th> <th>last update</th> <th>actions</th> </tr> </thead> <tbody> <?php foreach($query $record) : ?> <tr> <td><?php echo $record->id; ?></td> <td><?php echo word_limiter($record->title, 5); ?></td> <td><?php echo word_limiter($record->paragraph, 15); ?></td> <td><?php echo $record->lastupdate; ?></td> <td> <div class="btn-group btn-group-sm"> <a href="<?php echo base_url('gallery/view').'/'.$record->id; ?>" class="btn btn-info">view</a> <a href="#" class="btn btn-success">edit</a> <a href="" class="btn btn-danger" data-toggle="modal" data-target="#mymodal">delete</a> </div> </td> </tr> <div id="mymodal" 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">×</button> <h4 class="modal-title">delete</h4> </div> <div class="modal-body"> <p>are sure want delete? </p> </div> <div class="modal-footer"> <a href="<?php echo base_url('mywelcomepage/deletez').'/'.$record->id; ?>" class="btn btn-default" >yes</a> <button type="button" class="btn btn-default" data-dismiss="modal">no</button> </div> </div> </div> </div> <?php endforeach; ?> </tbody> </table> <?php endif; ?> </div>
use code not need add dynamic modal each time in view :)
<div class="table-responsive"> <?php if(sizeof($query) < 1) : ?> no record in database. <?php else : ?> <table class="table table-hover"> <thead> <tr> <th>id</th> <th>title</th> <th>content</th> <th>last update</th> <th>actions</th> </tr> </thead> <tbody> <?php foreach($query $record) : ?> <tr> <td><?php echo $record->id; ?></td> <td><?php echo word_limiter($record->title, 5); ?></td> <td><?php echo word_limiter($record->paragraph, 15); ?></td> <td><?php echo $record->lastupdate; ?></td> <td> <div class="btn-group btn-group-sm"> <a href="<?php echo base_url('gallery/view').'/'.$record->id; ?>" class="btn btn-info">view</a> <a href="#" class="btn btn-success">edit</a> <a href="" class="btn btn-danger" data-toggle="modal" onclick="confirm_modal('<?php echo site_url("controller/function/".$record->id);?>','title');" data-target="#mymodal">delete</a> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> <!-- (normal modal)--> <div class="modal fade" id="modal_delete_m_n" data-backdrop="static" data-keyboard="false"> <div class="modal-dialog"> <div class="modal-content" style="margin-top:100px;"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" style="text-align:center;">are sure delete <span class="grt"></span> ?</h4> </div> <div class="modal-footer" style="margin:0px; border-top:0px; text-align:center;"> <span id="preloader-delete"></span> </br> <a class="btn btn-danger" id="delete_link_m_n" href="">delete</a> <button type="button" class="btn btn-info" data-dismiss="modal" id="delete_cancel_link">cancel</button> </div> </div> </div> </div> <script> function confirm_modal(delete_url,title) { jquery('#modal_delete_m_n').modal('show', {backdrop: 'static',keyboard :false}); jquery("#modal_delete_m_n .grt").text(title); document.getelementbyid('delete_link_m_n').setattribute("href" , delete_url ); document.getelementbyid('delete_link_m_n').focus(); } </script> <?php endif; ?> </div>
Comments
Post a Comment