Hello Everybody,

I hope someone can help me, I have a table full of records from a data 
base, each row has a delete button so what I want to do is to show a 
"Yes/No" Javascript popup to confirm the delete action.

So far what I did is:

 *** controller ***
def Person():
    person = db(db.Person.id>0).select()
    class Virtual(object):
        def button(self):
          XML(A(SPAN(_class='glyphicon 
glyphicon-remove'),_id="delete",_onclick='myFunction()',_class='btn 
btn-default fechar Jview btn-xs')),_class='btn-group btn-group-justified 
JpositionA')
            return bts
    person.setvirtualfields(campos_virtual = Virtual())
    return dict(formListar=person)

*** View ***
<script>
function myFunction() {
    $('#myModal').modal('show');
    return false;
};

 function myFunctiondelete() {
 };
</script>

    <table id="tablaGenerica" class="tablaC table-striped hover 
cell-border" cellspacing="0" width="100%" >
<thead>
    <tr>
        <th>Name</th>
        <th>Surname</th>
        <th></th>
    </tr>
    <tbody>
        {{for person in formListar:}}
            <tr>
                <td>{{=person.Person.name}}</td>
                <td>{{=person.Person.surname}}</td>
                <td class="options">{{=person.campos_virtual.buttons}}</td>
            </tr>
    </tbody>
       {{pass}}
</thead>
</table>
<div id="myModal" class="modal fade">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
       <h4 class="modal-title">Confirmation </h4>
      </div>
      <div class="modal-body">
       <p>
          Are you sure you want to delete?
          </p>
      </div>
      <div class="modal-footer">
          <div class="col-md-6 col-md-offset-3 ">
        <button type="button" id="cancel" class="botones btn btn-secondary" 
data-dismiss="modal">No</button>
        <button type="button" id="warning" class="botones btn btn-warning" 
onclick="myFunctiondelete()";>Yes<span class="glyphicon 
glyphicon-remove"></span> </button>
         </div>

Basically, everytime I click on the button I defined on the controller it 
calls a function "myFunction()" which shows a Javascript modal with the 
Yes/No options. When I click on "Yes" it doesn't do anything because I 
don't know how to pass the id of that particular record.

Anyone knows an easier method or how can I pass the id of that particular 
record?

Thanks

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to