jQuery UI confirm dialog not returns true/false

前端 未结 5 1997
清歌不尽
清歌不尽 2021-01-06 13:14

I have jQuery UI confirm dialog:

function fnComfirm(title, content) {
    $(\"#dialog:ui-dialog\").dialog(\"destroy\");
    $(\"#dialog-confirm p\").html(con         


        
5条回答
  •  独厮守ぢ
    2021-01-06 13:45

    Here an approach that I use (You can take the general idea for your example)

    You need two buttons

    First one will be hidden and will be called as a result of clicking Yes in the confirm dialog, this hidden button will be the one that will call the server side method and will do the render using the f:ajax

    
    

    Second button will open the dialog, this button will also submit the form to the server with execute="@form" (in case you have selection column in table (select several columns in table and click button to delete) that you want to to update in the server bean for example)

    
        
    
    

    now to the implementation of the js function

    function openDialogFunc(data){
        if (data.status === 'success') {
            $('#dialog').dialog({
                        title: title,
                        resizable: false,
                        height: 200,
                         width: 486,
                         modal: true,
             buttons: {
                     "Ok": function() { 
                         $("#myHiddenButtonID").click();
                         $(this).dialog("close"); 
                     }, 
                     "Cancel": function() { 
                         $(this).dialog("close"); 
                     } 
                 }
             });
        }
    }
    

    Notice that only upon clicking the OK dialog button there will be an execution of your hidden button $("#myHiddenButtonID").click(); otherwise nothing will happen...

    took this from similar question that I have answered in the past How to implement JQuery confirm dialog with JSF

提交回复
热议问题