I want to show a jQuery dialog as conformation-popup, when the user clicks on a cancel link. ("Do you really want to cancel?")
jQuery(#{rich:element('cancel')}).click(function(event) {
var dialog = jQuery(#{rich:element('cancelDialog')});
if (dialog.is(':visible')) {
jQuery(#{rich:element('cancelDialog')}).dialog('close');
}
else {
jQuery(#{rich:element('cancelDialog')}).dialog('open');
event.preventDefault();
}
});
<h:commandLink action="cancel" immediate="true" id="cancel" value="cancel" />
The dialog is opening, but the event won't be canceled (--> the cancel event is proceeded). When i use a h:commandButton instead, it works, but the customer wants this as a link.
I use JSF 2.0 (MyFaces), jQuery 1.6.1, Spring Webflow 2.3.0.RELEASE and as JSF Framework Richfaces 4.0.0.FINAL. Does anyone knows a solution with these frameworks? I can't use other frameworks.
Thank you, Patrick
Use return false in the function instead of event.preventDefault()
To learn more about the difference: The difference between ‘return false;’ and ‘e.preventDefault();’
EDITED
Since it still not work, I suggest use the onmousedown event instead of click, with the same function. JSF h:commandLink and onclick events
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With