Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
Jquery trigger.click with variables

Does anyone have a solution for submitting variable data with the trigger click function. In the example below, when a table row is clicked, a bootstrap modal is opened. The relevant table row data is passed to the modal and a form in the modal can be submitted. If there is an error processing the data, when receiving the error I would like to trigger a click on the respective table row and pass the row data to the Jquery function, to reopen the modal so the user can re-submit the form. I've read the trigger click function does not work exactly like a click, but is there a way of doing this?

<table class="table table-striped" width="100%" id="ModalTable">
    <thead class="thead-dark">
        <tr>
            <th>Job No</th><th>Client</th><th>Location</th><th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr id="j421" data-cln="MY CO LTD" data-loc="My Road" data-des="My Work" data-toggle="modal" data-target="#myModal">
            <td>ABC/J421</td><td>MY CO LTD</td><td>My Road</td><td>My Work</td>
        </tr>
        <tr id="j422" data-jnod="ABC/J422" data-eno="31" data-task="new" data-jno="422" data-jtype="std" data-cln="YOUR CO LTD" data-loc="Your Road" data-des="Your Work" data-toggle="modal" data-target="#myModal">
            <td>ABC/J422</td><td>YOUR CO LTD</td><td>Your Road</td><td>Your Work</td>
        </tr>
    </tbody>
</table>

<?php if (session()->has('error_message')) : ?>
    <?= 
        "<script>   
            $('#j".old('job_no')."').trigger('click')" 
        </script>"
    ?> 
<?php endif ?>
<script>
$('<?= lang($lang.'.modaltarget') ?>').on('show.bs.modal', function (event) {
    var tr = $(event.relatedTarget);

    var client_name = tr.data('cln');
    var location = tr.data('loc') ;
    var descr = tr.data('des');
    
    var modal = $(this);

    modal.find('.modal-body #client_name').val(client_name);
    modal.find('.modal-body #location').val(location);
    modal.find('.modal-body #descr').val(descr);

    modal.find('#body_message').hide();
    modal.find('#body_content').show();
});
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can send additional params with click trigger.

$( "p" )
  .click(function( event, a, b ) {
    // When a normal click fires, a and b are undefined
    // for a trigger like below a refers to "foo" and b refers to "bar"
  })
  .trigger( "click", [ "foo", "bar" ] );

source

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda