开发者

give name and value to jquery UI dialog button...

i want to give a name and value to the default button in UI dialog. how can i do tha开发者_如何学运维t ? 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');
});


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');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜