PrimeFaces as background in DropList

0
Well I'm using PrimeFaces in my project and I came across the following situation, when I have an altered field that is different from the original, I have to leave a background in yellow color more specifically, however that is working in other fields which are inputText but when DropList or AutoComplete does not work, does anyone have an idea how to do it?

Code of how I'm doing below:

function verificaValorComValorOriginal () {

    debugger;

    // Dados Básicos
    if ($('#nomePessoa').val() != null && $('#nomePessoaOriginal').val() != null) {
        if ($('#nomePessoa').val() != $('#nomePessoaOriginal').val()) {
            $('#nomePessoa').attr("style","background: yellow;");
            $('#nomePessoaOriginal').attr("style","background: yellow;");
        }
    }

    if ($('#apelido').val() != null && $('#apelidoOriginal').val() != null) {
        if ($('#apelido').val()!= $('#apelidoOriginal').val()) {
            $('#apelido').attr("style","background: yellow;");
            $('#apelidoOriginal').attr("style","background: yellow;");
        }
    }

    if ($('#sexo').val() != null && $('#sexoOriginal').val() != null) {
        if ($('#sexo').val() != $('#sexoOriginal').val()) {
            $('#sexo').attr("style","background: yellow;");
            $('#sexoOriginal').attr("style","background: yellow;");
        }
    }

    if ($('#dataNascimento').val() != null && $('#dataNascimentoOriginal').val() != null) {
        if ($('#dataNascimento').val() != $('#dataNascimentoOriginal').val()) {
            $('#dataNascimento').attr("style","background: yellow;");
            $('#dataNascimentoOriginal').attr("style","background: yellow;");
        }
    }

    if ($('#estadoCivil').val() != null && $('#estadoCivilOriginal').val() != null) {
        if ($('#estadoCivil').val() != $('#estadoCivilOriginal').val()) {
            $('#estadoCivil').attr("style","background: yellow;");
            $('#estadoCivilOriginal').attr("style","background: yellow;");
        }
    }

This is a small example of the code, for example this CivilCode is a DropList and does not work when the value is different. I'm using PrimeFaces 6.2.

Solution:

if ($('#estadoCivil').val() != null && $('#estadoCivilOriginal').val() != null) {
    if ($('#estadoCivil').val() != $('#estadoCivilOriginal').val()) {

        $(".pui-dropdown-label").each(function() {

            if ($(this).context.parentElement.innerHTML.indexOf('estadoCivil') > 0) {
                $(this).attr("style","background: yellow;");
            }

        });
    }
}

For the time being I got the above solution.

    
asked by anonymous 27.10.2018 / 07:14

1 answer

0

Solution:

if ($('#estadoCivil').val() != null && $('#estadoCivilOriginal').val() != null) {
    if ($('#estadoCivil').val() != $('#estadoCivilOriginal').val()) {

        $(".pui-dropdown-label").each(function() {

            if ($(this).context.parentElement.innerHTML.indexOf('estadoCivil') > 0) {
                $(this).attr("style","background: yellow;");
            }

        });
    }
}

For the time being I got the above solution.

    
29.10.2018 / 07:23