Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda