jQuery UI 对话框按钮文本作为变量

标签 jquery jquery-ui variables jquery-ui-dialog

谁能告诉我如何在 jQuery UI 对话框中使用按钮文本变量? 我想制作一个动态按钮名称。

最佳答案

由于 jQuery 处理按钮名称的方式(可以带或不带引号),这将不起作用

这会起作用:

var button_name = 'Test';
var dialog_buttons = {}; 
dialog_buttons[button_name] = function(){ closeInstanceForm(Function); }
dialog_buttons['Cancel'] = function(){ $(this).dialog('close'); }   
$('#instanceDialog').dialog({ buttons: dialog_buttons });

关于jQuery UI 对话框按钮文本作为变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1464843/

相关文章:

javascript - 每日、每周、每月套餐的价格选项

javascript - jquery droppable 在放置后添加 css

c++ - "Only static constant integral variables may be initialized within a class "

javascript - 滚动后更改导航栏颜色?

jquery - 拖动下面的图像并调整上面的 DIV 的大小

javascript - 在 Chrome 中按比例调整图像大小

xml - 处理 XSLT 中的 namespace 和变量

java - 如何读写抽象类的变量

javascript - Bootstrap 两个响应式菜单 - 单击另一个菜单按钮时折叠一个菜单

javascript - 无法加载较高质量的较低质量图像