Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Finally could make it work. here a short version of this (without ajax and smarty and harcoded users) online and working: </p> <p><a href="http://bootply.com/97366" rel="nofollow">http://bootply.com/97366</a></p> <p><strong>View:</strong></p> <pre><code>&lt;tbody&gt; {foreach $frontusers as $frontuser} &lt;tr&gt; {if $frontuser-&gt;frontavatar_id eq null} &lt;td&gt;&lt;img src="{site_url()}assets/img/avatar.png" alt="" /&gt;&lt;/td&gt; {else} &lt;td&gt;&lt;img src="{site_url()}assets/img/avatar1.jpg" alt="" /&gt;&lt;/td&gt; {/if} &lt;td class="hidden-phone"&gt;{$frontuser-&gt;username}&lt;/td&gt; &lt;td&gt;{$frontuser-&gt;name}&lt;/td&gt; &lt;td&gt;{$frontuser-&gt;lastname}&lt;/td&gt; &lt;td class="hidden-phone"&gt;{$frontuser-&gt;email}&lt;/td&gt; &lt;td class="hidden-phone"&gt;{$frontuser-&gt;state}&lt;/td&gt; &lt;td class="hidden-phone"&gt;{$frontuser-&gt;creation_date|date_format:"%Y/%m/%d"}&lt;/td&gt; {if $frontuser-&gt;status eq 2} &lt;td &gt;&lt;span class="label label-success"&gt;Activo&lt;/span&gt;&lt;/td&gt; {else} &lt;td &gt;&lt;span class="label label-warning"&gt;No Activo&lt;/span&gt;&lt;/td&gt; {/if} &lt;td&gt;&lt;a class="btn mini blue-stripe" href="{site_url()}admin/editFront/{$frontuser-&gt;id}"&gt;Edit&lt;/a&gt;&lt;/td&gt; //here in data-title i store the username so later i can "catch it" in the jquery function &lt;td&gt;&lt;a href="#" class="confirm-delete btn mini red-stripe" role="button" data-title="{$frontuser-&gt;username}" data-id="{$frontuser-&gt;id}"&gt;Delete&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;!-- modal --&gt; &lt;div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&lt;/button&gt; &lt;h3 id="myModalLabel3"&gt;Delete&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;p&gt;&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Cerrar&lt;/button&gt; &lt;button data-dismiss="modal" class="btn red" id="btnYes"&gt;Confirmar&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- end modal --&gt; {foreachelse} //no users are in the db &lt;tr&gt; &lt;td colspan="2"&gt;&lt;span class="text-error"&gt;&lt;i class="icon-exclamation"&gt;&lt;/i&gt; No hay Usuarios cargados.&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; {/foreach} &lt;/tbody&gt; </code></pre> <p><strong>Js File:</strong></p> <pre><code>//after first function is triggered, modal shows and this function runs $('#myModal').on('show', function() { //catch the id for later deletion, and username to display on modal var id = $(this).data('id'), username = $(this).data('usern'); $('#myModal .modal-body p').html("Do you want to delete user: " + '&lt;b&gt;' + username + '&lt;/b&gt;' + ' ?'); }) //when clicking "delete" button from a row, this is the first function that runs $('.confirm-delete').on('click', function(e) { e.preventDefault(); //catch the user id and username var id = $(this).data('id'); var user = $(this).data('title'); //assign to the modal id and username $('#myModal').data('id', id).modal('show'); $('#myModal').data('usern', user).modal('show'); }); $('#btnYes').click(function() { var id = $('#myModal').data('id'); //sending to php the row to be deleted from the db $.ajax({ url: 'deleteFrontUser', type: 'POST', data: 'id='+id, success: function(html){ //removing entire row $('[data-id='+id+']').parents('tr').remove(); $('#myModal').modal('hide'); } }); return false; }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload