Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to create invisible divs with jQuery which in title will be populated dinamically by an struts tag, but its giving me invalid indexed property error:

Java
Invalid indexed property 'niveisRisco['+<%=ctr%>+']


Heres the code i'm using:

JavaScript
$(function(){
        var mapaAplicacaoJs = $('#MapaAplicacao area'); 
        var mapaPerfilJs = $('#MapaPerfil area');

       <logic:present name="carteiraSelecionada">
        <logic:iterate name="carteiraSelecionada" property="carteiraAtual.niveisRisco" id="foo" indexId="ctr">
            mapaAplicacaoJs.each(function() {  
                mapaAplicacaoJs.before('<div id="nivel_risco_dv" class="tabindex" title="<bean:write name="carteiraSelecionada" property="carteiraAtual.niveisRisco['+<%=ctr%>+'].getDescricao" />"></div>');
         </logic:iterate>
        </logic:present>        
        });


If i hardcode

Can anyone tell me whats wrong with my concatenation?

Thanks
Posted
Comments
Kornfeld Eliyahu Peter 4-Nov-14 9:38am    
Something wrong with your code samples - it looks like you have some tags in the middle of a JS method...Alos parts of the code you copied is invisible...
Please fix it...
Shubhashish_Mandal 5-Nov-14 6:48am    
javascript unable to parse this <%=ctr%> , instead try EL tag(i.e ${}) to represent the variable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900