jQuery UI对话框按钮文本作为变量 [英] jQuery UI dialog button text as a variable
本文介绍了jQuery UI对话框按钮文本作为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我如何在jQuery UI对话框中为按钮文本使用变量? 我想创建一个动态按钮名称.
Can anyone tell me how can i use a variable for button text in jQuery UI dialog? I want to make a dynamic button name.
推荐答案
由于jQuery处理按钮名称的方式(可以带引号或不带引号),因此无法使用
This won't work because of the way jQuery handles the button name (can be with or without quotes)
这将起作用:
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对话框按钮文本作为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文