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

前端 未结 2 731
执笔经年
执笔经年 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

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

提交回复
热议问题