assign id to jquery dialog button

后端 未结 5 1235
小蘑菇
小蘑菇 2021-01-30 10:49

How do i assign an an id to a jquery dialog button. I tried the following but it\'s not working

buttons: {
Ok: function() {
id=\"xyz\",
...
相关标签:
5条回答
  • 2021-01-30 11:34

    @BerndB: Thanks it works perfectly and even is more extendable.

    $('#loginlink').live('click',function(){
        DC = 'login_box';
        diaOpt = {
            autoOpen : true,
            width : 400,
            title : 'Login',
            buttons: {
                //valiudate login
                'Login' : {
                    text : 'Login Now',
                    id : 'validateForm',
                    click : function(){
                    }   
                }
            }
        }
    
        launchDialog(diaOpt, DC);
    });
    
    $('#validateForm').live('click', function(){
        alert('Hellop');
        $("#loginform").validate();
    });
    
    0 讨论(0)
  • 2021-01-30 11:44

    This code from official site worked for me:

    $('#dialog').dialog({
        // properties ... 
        buttons: [{
            id:"btn-accept",
            text: "Accept",
            click: function() {
                $(this).dialog("close");
            }
        }, 
        {
            id:"btn-cancel",
            text: "Cancel",
            click: function() {
                $(this).dialog("close");
            }
        }]
    });
    
    0 讨论(0)
  • 2021-01-30 11:46

    Try this.

    buttons: {
        'MyButton': function() {
            //... configure the button's function
        }
    

    And the id setter

    $('button:contains(MyButton)').attr("id","xyz");  
    
    0 讨论(0)
  • $("#OK",{id:'xyz'});
    

    hope that it helps

    0 讨论(0)
  • The following (seemingly undocumented) works for me with jQuery 1.8.9:

    $("#dlg").dialog({
      buttons :  { 
         "MyButton" : {
             text: "My Button",
             id: "my-button-id",
             click: function(){
                 alert("here");
             }   
          } 
       }
    });
    

    The button can be addressed via $("#my-button-id")

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