jQuery UI对话框链接而不是按钮
问题描述:
我喜欢添加一个按钮(默认情况下受支持)并链接jQuery UI对话框.如何在jQuery UI对话框中添加链接?就我而言,我喜欢具有保存"按钮和取消"链接.预先感谢.
I like to add a button (which is supported by default) and link jQuery UI dialog. How to add a link in jQuery UI dialog? In my case I like to have Save button and a Cancel link. Thanks in advance.
答
您将不得不按照所需的样式来设置按钮的样式,但这会注入一个链接并将绑定的点击绑定到您想做的事情上.
You will have to style the button how you want to, but this injects a link and binds the click even to do what you want.
$("#dialog").dialog({
modal: true,
open: function(event, ui){
$('<a />', {
'class': 'linkClass',
text: 'Cancel',
href: '#'
})
.appendTo($(".ui-dialog-buttonpane"))
.click(function(){
$(event.target).dialog('close');
});
},
buttons: {
'Save': function() {
//save code here.
}
}
});