I\'m just starting out in JSF, looks awesome, but I can\'t seem to figure out this last barrier.
I\'m used to traditional Jquery AJAX function, which is perfect in m
add the onevent="jsFunctionName"
(no brackets) needed to your <f:ajax
and your jsFunctionName
should look like
function openDeleteDevicesDialog(data) {
console.log(data.status); //while ,data.status can be 1)"begin" 2)"complete" 3)"success"
if (data.status === 'begin') {...}
if (data.status === 'complete') {...}
if (data.status === 'success') {...}
}
so you should enter this function 3 times
the onclick of the h:commandButton
is executed before the f:ajax
even begins...)
Note that usually you will execute your code in the when data.status === 'success'
, its when your page is done rendering and your DOM is in its final shape/state
also take a look at BalusC answer over here...
is this what you are looking for? How can I execute Javascript before a JSF <h:commandLink> action is performed? (you will have to change the link to the button)
If you see this button being used everywhere on your web site, you can also create a custom tag.