这里有我的Add to library
按钮。如何在其中添加id
?
Utils.dialog({
message: save_graph_canvassheet_html,
title: 'Add graph to canvas library',
buttons: {
'Add to library': function () {
var form = $(this).closest('.content');
var title = form.find('input[name="title"]').val()
var date_option = form.find('input[name="date_option"]:checked').val()
if (!title) {
alert($.i18n._('Please enter a title'));
return false;
}
Utils.status({
id: 'add_canvas_sheet',
text: 'Adding element to library'
})
graph_params.class_str = instrument_class_name;
delete graph_params.graph_height;
delete graph_params.graph_width;
delete graph_params._;
$.ajax({
url: '/ajax/CanvasSheet/add_element',
type: 'POST',
async: false,
data: {
title: title,
params: graph_params,
type: 'graph',
date_option: date_option
},
success: function (response) {
if (response.success) {
$('#canvassheets_dialog').trigger('refresh_elements');
}
Utils.status({
id: 'add_canvas_sheet'
})
}
})
}
},
modal: false
})
答案 0 :(得分:0)
基于LintonB对这个线程的回答:
jQuery Ui Dialog Buttons, How to add class?
我想你可以做这样的事情:
Utils.dialog({
message: save_graph_canvassheet_html,
title: 'Add graph to canvas library',
buttons: {
'Add to library': {
click: function () {
var form = $(this).closest('.content');
var title = form.find('input[name="title"]').val()
var date_option = form.find('input[name="date_option"]:checked').val()
if (!title) {
alert($.i18n._('Please enter a title'));
return false;
}
},
text: 'Add to library',
id: 'buttonID'
}