views:

26

answers:

1

Hi, i want to give a name and value to the default button in UI dialog. how can i do that ? i would like to give to submit button a value and name!

$("#dialog").dialog({
    bgiframe: true,
    autoOpen: false,
    height: 150,
    width: 600,
    modal: true,
    buttons: {
        Submit: function() {
                  document.getElementById('form').submit();
          $(this).dialog('close');
        },
        Cancel: function() {
            $(this).dialog('close');
        }
    }
});
$('#beleg_sichern').click(function() {
    $('#dialog').dialog('open');
});
A: 

No nice way to do this really since the dialog button constructor only allows you to express the text of the button and the click function.

One way is to set these before submitting the form.

$("#dialog").dialog({
    bgiframe: true,
    autoOpen: false,
    height: 150,
    width: 600,
    modal: true,
    buttons: {
        Submit: function(ev) {
          var btn = ev.target;
          btn.value = 'someValue';
          btn.name = 'someName';
          btn.form.submit();
          $(this).dialog('close');
        },
        Cancel: function() {
            $(this).dialog('close');
        }
    }
});
$('#beleg_sichern').click(function() {
    $('#dialog').dialog('open');
});
redsquare
didnt worked :(
Pezhman Fallahi
@Pezhman Fallahi - in what sense did it not work. What is the expected outcome. Can you give more info!
redsquare
@Pezhman Fallahi answer amended - try the above
redsquare
i have tried to set the name as you did for the submit button, but when i open the modal and check the button html, there is no name set for the button!! i have a php form in the modal which looking for the name of the submit button and when it can not find the name of the button it is not submitting the form!!!
Pezhman Fallahi
@Pezhman Fallahi it will set the name when you click the button. When do you want it changed? and for what purpose?
redsquare