Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/04/2014, 05:53
beto13
 
Fecha de Ingreso: junio-2013
Ubicación: Argentina
Mensajes: 24
Antigüedad: 10 años, 10 meses
Puntos: 0
Respuesta: Valor de un dataTable no llega por POST

Cita:
Iniciado por Djoaq Ver Mensaje
allí le estas pasando a tu funcion buscarPersonal valor input o atrributo value del form pero no entiendo porque aqui le pones this?
el this lo uso para obtener el valor del objeto tratado, en este caso el botón


Cita:
Iniciado por Djoaq Ver Mensaje
allí le estas pasando a tu funcion buscarPersonal valor input o atrributo value del form pero no entiendo porque aqui le pones this?

y aquí no ?
Código Javascript:
Ver original
$('#frmListadoPersonal').submit()
En el else no uso la función buscarPersonal porque la cargo en el evento ready de la otra página.
El form en cuestión es el siguiente:

Código HTML:
Ver original
  1. <form id="frmListadoPersonal" method="post" action="personal.php">
  2.         {% if lenguaje == 'es' %}
  3.             <input type="hidden" id="hdnLanguage" value="{{ lenguaje }}" >
  4.             {% else %}
  5.             <input type="hidden" id="hdnLanguage" value="" >
  6.         {% endif %}
  7.         <button class="btn btn-danger">Nuevo Empleado</button>
  8.         <div class="table-responsive">
  9.             <table  id="tbPersonal" class="table table-striped">
  10.                 <thead>
  11.                     <tr>
  12.                         <th>Apellido</th>
  13.                         <th>Nombre</th>
  14.                         <th>Cargo</th>
  15.                         <th>Pais</th>
  16.                         <th>&nbsp;</th>
  17.                         <th>&nbsp;</th>
  18.                     </tr>
  19.                 </thead>
  20.             </table>
  21.         </div>
  22.     </form>

el table se carga con la siguiente función

Código Javascript:
Ver original
  1. function listarPersonal(){
  2.         $.ajax({
  3.             url: 'procesar_buscar.php',
  4.             type: 'POST',
  5.             data: { tarea: 'listarPersonalPaginado'},
  6.             dataType: 'json',
  7.             success: function (data) {
  8.                 if (data.success) {
  9.                     $.each(data, function (index, record) {
  10.                         if ($.isNumeric(index)) {
  11.                             var row = $("<tr />");
  12.                             var edit = '<button name="btnEditar" class="btn btn-default btn-mini" value="'+record.codpersonal+'"><i class="glyphicon glyphicon-pencil"></i></button>';
  13.                             var remove = '<button name="btnEliminar" class="btn btn-default btn-mini" value="'+record.codpersonal+'" data-toggle="modal" data-target="#divBajaPersonal"><i class="glyphicon glyphicon-remove"></i></button>';
  14.                             $("<td />").text(record.apellidos).appendTo(row);
  15.                             $("<td />").text(record.nombres).appendTo(row);
  16.                             $("<td />").text(record.cargo).appendTo(row);
  17.                             $("<td />").text(record.pais).appendTo(row);
  18.                             $("<td />").html(edit).appendTo(row);
  19.                             $("<td />").html(remove).appendTo(row);
  20.                             row.appendTo("#tbPersonal");
  21.                         }
  22.                     })
  23.                 }
  24.  
  25.                 $('#tbPersonal').dataTable({
  26.                     "sPaginationType": "full_numbers",
  27.                     "oLanguage": {
  28.                         "sUrl": "dataTables.spanish.txt"
  29.                     }
  30.                 })
  31.             }
  32.         });
  33.     }