Jquery dialog buttons return value

前端 未结 2 757
闹比i
闹比i 2021-01-26 23:17

I am using a jquery dialog, and what i want to implement is when user press \"ok“, the progamming keep going, when press \"cancel\", it stoped.

    function dis         


        
相关标签:
2条回答
  • 2021-01-26 23:47
    function displaymessage()
    {
     $("#confirm").dialog({
        autoOpen:false,        
        buttons:{
                    "OK":function(){  test(1); $(this).dialog("close"); },
                    "Cancel":function(){ test(0); $(this).dialog("close");}        
                }
            });  
    }
    
    
    function test(bool)
    {
      if(bool==1)
          return  true;
      else 
          return false;
    }
    
    0 讨论(0)
  • 2021-01-26 23:48

    Take 2 buttons

    <asp:button id="submit" onclientclick="return displaymessage()" />
    
    <asp:button id="submit_hidden" onclick="submit_OnClick" runat="server"/>
    

    Hide the button with id submit_hidden. (may be via css dsiplay:none;)

    And in jquery change the code

    $("#confirm").dialog({
        autoOpen:false,        
        buttons:{
                    "OK":function(){ $("#submit_hidden").click();
                                     $(this).dialog("close"); },
                    "Cancel":function(){ $(this).dialog("close");}        
                }
            });  
    

    Now you don't need to return anything.

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