I am working with JSF, Primefaces and Bootsfaces. I am developing a navbar and I must create a dropmenu in navbar, however I had a problem with b:dropmenu
implementation and I used another solution.
My problem is when I on click in Nombre de usuario
the page reloads if I call mostrarOpcionesUsuario()
, but if I replace mostrarOpcionesUsuario();
to alert('hello!');
, the system shows alert
and doesn't refresh the page. I need to call mostrarOpcionesUsuario()
without refreshing the page.
This is my code:
XHTML:
<b:navbar>
<b:navbarLinks>
<b:navLink onmousedown= "mostrarOpcionesUsuario(); return false;">
<div>
<ul>
<li>
<div>
<span>
Nombre de usuario
</span>
</div>
<ul class = "ulOpciones">
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
</ul>
</li>
</ul>
</div>
</b:navLink>
</b:navbarLinks>
</b:navBar>
JavaScript:
function mostrarOpcionesUsuario() {
$(".ulOpciones").css('visibility', function (i, v) {
if (v == 'hidden') {
$(".ulOpciones").css({'visibility': 'visible'});
} else {
$(".ulOpciones").css({'visibility': 'hidden'});
}
});
}
Is the same case if I put alert
in mostrarOpcionesUsuario()
, the page doesn't reload, but with the previous mostrarOpcionesUsuario
implementation, the page reloads.
Help me, please!
Thank you!