Get parameter in . equal click pass onClick - jQuery

Asked

Viewed 42 times

0

I have the following iterator that has delete buttons that are dynamically loaded:

<s:iterator value="form.listaCooperativa" id="lista" status="lista_status">
    <s:if test="#lista_status.odd == true">
        <tr>
    </s:if>
    <s:else>
        <tr class="linha-alternada">
    </s:else>
    <td align="center">
        <s:a href="javascript:;" onclick="abrirFormAlterar('%{idCooperativa}');" title="Alterar">
            <s:property value="pessoaJuridica.nrCpfCnpjFormatado" />
        </s:a>
    </td>
    <td align="left"> <s:property value="pessoaJuridica.nmEmpresarial" /></td>
    <td align="left"> <s:property value="apelido[0].nmApelido" /></td>
    <td align="center">
        <sisprocer:botao key="mantercooperativa.label.button.excluir" title="Excluir" id="excluir-dialog-confirm-link"/>
    </td>
</s:iterator>

These delete buttons open a dialog:

function configuraPopups(){
    $('#excluir-dialog-confirm').dialog({
        autoOpen  :false,
        modal    :true,
        resizable :false,
        buttons: {
            "Cancelar": function() { 
                $(this).dialog("close"); 
            }, 
            "Ok": function() {
                $(this).dialog("close");  
                //excluir(idCooperativa) QUERO ENVIAR O ID AQUI!
            } 
        }
    });

    // Dialog confirm link
    $('#excluir-dialog-confirm-link').click(function(){
        var id = $(this).attr('%{idCooperativa}'); //QUERO RECEBER O ID AQUI
        $('#excluir-dialog-confirm').dialog('open');
        return false;
    });

}

But I would like to get the idCooperative in the related object dialog, as if it were sending for example = onClick('%{idCooperative}');

I have problems using onClick because the button is already standardized for Submit due to the framework, that is, I need to recover this way so that I could send the method related to the parameter when clicking ok, as for example:

"Ok": function() {
    $(this).dialog("close");  
    excluir(idCooperativa);
} 

How can I receive this parameter in this location? Remembering that for each button I have a different id.

  • 1

    That one id="excluir-dialog-confirm-link" is generated multiple times? Cannot generate repeated id’s.

  • 1

    Friend I’ll give you rich advice: Exchange these IDS for class. in class you take the value, take the id, take what you want.

  • @Sam, truth hadn’t thought of it, but there was no sign of error on that, which you think would be a good solution?

  • @Riscadooooooerabiscadoo problem that is legacy system and should be maintained standardization.

  • If you put two repeat Ids at the end of the project... you will have a ghost legacy.

  • Go to www.meuposto.ml/1.html to try to help you

  • No error, but repeating id’s causes problems. If vc cannot change this, you can select the button by another attribute, type $("#lista [title=Excluir]")

Show 2 more comments

1 answer

0

  • yes but to use the default prevente I must use the . click and not onClick, for the . click I don’t have Submit, but I can’t pass the parameter, this is my question

  • What framework are you using? Every button element exposes the click event with the features I commented, maybe in your case there is a layer more...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.