JSF and Jquery AJAX - How can I make them work together?

前端 未结 2 732
执笔经年
执笔经年 2021-01-06 16:11

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

相关标签:
2条回答
  • 2021-01-06 17:05

    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...

    0 讨论(0)
  • 2021-01-06 17:06

    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.

    0 讨论(0)
提交回复
热议问题