2
I’m using javascript to select the menu to open the page I selected, the menu is already being selected but is not opening the pages. And the click event is working when I click on the menu.
$(document).ready(function() {
$('ul.form li a').click(
function(e) {
e.preventDefault(); // prevent the default action
e.stopPropagation; // stop the click from bubbling
$(this).closest('ul').find('.selected').removeClass('selected');
$(this).parent().addClass('selected');
alert('Chegou !!'); // Para testar o evento...
});});
Menu.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<nav class="aw-menu">
<ul class="form">
<li class="selected">
<h:link class="a" outcome="/page/main.xhtml"><i class="fa fa-fw fa-home"></i>Início</h:link>
</li>
<li>
<h:link outcome="/page/req/cons_requerimento.xhtml"><i class="fa fa-fw fa-newspaper-o"></i>Bônus Pecuniário</h:link>
</li>
<li>
<h:link outcome="/page/seg/cons_usuario.xhtml"><i class="fa fa-fw fa-user"></i>Usuários</h:link>
</li>
<li>
<h:link outcome="/page/seg/form_usuario_alt_senha.xhtml"><i class="fa fa-fw fa-lock"></i>Alterar Senha</h:link>
</li>
</ul>
</nav>
Ev.Preventdefault() prevents your page from being redirected by clicking, you will need to take the page link and open it by javascript
– Guilherme Lopes
How do I do it ?
– robsonp
You can take the href attribute from the link and then take a window.location.href, you know ?
– Guilherme Lopes
I tried here but I still can’t get
– robsonp