我无法将按钮添加到此jquery ui对话框。如果可能的话,请给我举个例子。谢谢。
<script type="text/javascript">
$(document).ready(function () {
//setup new person dialog
$('#dialog2').dialog({
autoResize: true,
show: "clip",
hide: "clip",
height: 'auto',
width: '1000',
autoOpen: false,
modal: true,
position: 'top',
draggable: false,
title: "انتخاب درخواست",
open: function (type, data) {
$(this).parent().appendTo("form");
}
});
$('#viewfaktor').dialog({
autoResize: true,
show: "clip",
hide: "clip",
height: 'auto',
width: '1000',
autoOpen: false,
modal: true,
position: 'top',
draggable: true,
title: "مشاهده صورت ریز",
open: function (type, data) {
$(this).parent().appendTo("form");
}
});
$('#msgBox').dialog({
autoResize: true,
show: "clip",
hide: "clip",
height: 'auto',
width: 'auto',
autoOpen: false,
modal: true,
position: 'center',
draggable: false,
open: function (type, data) {
$(this).parent().appendTo("form");
}
});
});
function showDialog(id) {
$('#' + id).dialog("open");
}
function closeDialog(id) {
$('#' + id).dialog("destroy");
}
</script>
发布于 2010-10-27 17:30:06
$('#msgBox').dialog({
autoResize: true,
show: "clip",
hide: "clip",
height: 'auto',
width: 'auto',
autoOpen: false,
modal: true,
position: 'center',
draggable: false,
open: function (type, data) {
$(this).parent().appendTo("form");
},
buttons: { "OK": function() { $(this).dialog("close"); } }
});
发布于 2011-09-16 03:33:03
有时,您也希望在创建对话框后动态添加按钮。请参阅问题Add a button to a dialog box dynamically上的my answer
var mydialog = ... result of jqueryui .dialog()
var buttons = mydialog.dialog("option", "buttons"); // getter
$.extend(buttons, { foo: function () { alert('foo'); } });
mydialog.dialog("option", "buttons", buttons); // setter
发布于 2012-06-14 23:06:35
如果要向已打开的对话框中添加按钮,可以执行以下操作:
var buttonSet = $('#dialog').parent().find('.ui-dialog-buttonset');
var newButton = $('<button>My New Button</button>');
newButton.button().click(function () {
alert('My new button clicked');
});
buttonSet.append(newButton);
https://stackoverflow.com/questions/4031673
复制相似问题