jquery - 我想为 utils 对话框中的按钮添加 id
问题描述
在这里,我有我的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
})
解决方案
Based on LintonB's answer of this thread:
jQuery Ui Dialog Buttons, How to add class?
I guess you can do something like this:
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'
}
推荐阅读
- java - Logging 类的构造函数在 Java 1.8.0_211 中没有被调用,但在 Java-1.8.0_0 中工作
- python - 使用 Python Pandas 保存到文件时如何正确格式化 JSON?
- python - 将现有权限添加到 Django 中的组的最佳方法
- java - Java并行化批处理
- javascript - 悬停时获取ant-design Select下拉值
- ios - 在 iOS webview 中向后滑动
- reactjs - 当用户进行不断的增量更改时,如何避免对数据库的不断更新?
- azure-keyvault - 如何在二头肌中引用现有的证书资源?
- python - 使用 numpy 的离散傅里叶变换采样频率
- javascript - 输入固定值