Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

69
Views
assign id to jquery dialog button

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",
...
9 months ago · Santiago Trujillo
3 answers
Answer question

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")

9 months ago · Santiago Trujillo Report

0

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");
        }
    }]
});
9 months ago · Santiago Trujillo Report

0

@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();
});
9 months ago · Santiago Trujillo Report
Answer question
Find remote jobs