Note that there are some explanatory texts on larger screens.

plurals
  1. POsend parameter to a modal and then deleting row
    primarykey
    data
    text
    <p>After 2 days of researching i decided to ask for some help because i can't move on.</p> <p>I display a users table in my site. Each row has user's data and a delete user button.</p> <p>If you press on delete button, a modal has to show up asking you if you want to delete that certain user. That is why i have to send a parameter that is the username.</p> <p>That modal is a confirm modal with the legend: Are you sure you want to delete //username//?</p> <p>The thing is that i know how to send the parameter but can't integrate it with jquery deletion function. Also don't have a very clear idea of how to delete a row since i'm really newbie with js and jquery.</p> <p>So far this is what i have (please notice that im using Smarty template engine):</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;Modificar&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="#" data-id="{$frontuser-&gt;id}" class="btn mini red-stripe confirm-delete" role="button"&gt;Delete&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;!-- modal --&gt; &lt;div id="myModal3" 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;Are you sure you want to delete user ....?&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt; &lt;button data-dismiss="modal" class="btn red" id="btnYes"&gt;Confirm&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- end modal --&gt; {foreachelse} &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>this is my js file (i got it from <a href="http://bootply.com/61026" rel="nofollow">this link</a> )</p> <pre><code>$('#myModal3').on('show', function() { var id = $(this).data('id'), removeBtn = $(this).find('.red'); }) $('.confirm-delete').on('click', function(e) { e.preventDefault(); var id = $(this).data('id'); $('#myModal3').data('id', id).modal('show'); }); $('#btnYes').click(function() { // handle deletion here var id = $('#myModal3').data('id'); $('[data-id='+id+']').remove(); $('#myModal3').modal('hide'); }); </code></pre> <p>So, to sum up i need to adapt my code to do the following:</p> <ol> <li>Send the username as a parameter to the modal</li> <li>Delete entire row if confirm button is pressed</li> </ol> <p><strong>UPDATE:</strong></p> <p>The modal is working, i mean, it opens and closes. modal's Confirm button only deletes "delete button" from the row, not the entire row.</p>
    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.
 

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