我在完成一项相对简单的任务时遇到了麻烦。我正在使用jAlerts(http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/),我知道它不再受支持,并尝试将按钮的文本更改为变量。
截至目前,这是jAlerts的开始代码,其中按钮被定义为字符串:
$.alerts = {
// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
repositionOnResize: true, // re-centers the dialog on window resize
overlayOpacity: .01, // transparency level of overlay
overlayColor: '#FFF', // base color of overlay
draggable: true, // make the dialogs draggable (requires UI Draggables plugin)
okButton: 'Ok', // text for the OK button
cancelButton: 'Cancel', // text for the Cancel button
deleteButton: 'Delete', // text for the remove button
dialogClass: null, // if specified, this class will be applied to all dialogs
我要做的是用变量替换它们(在这种情况下我使用的是大型JS数组):
$.alerts = {
// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
repositionOnResize: true, // re-centers the dialog on window resize
overlayOpacity: .01, // transparency level of overlay
overlayColor: '#FFF', // base color of overlay
draggable: true, // make the dialogs draggable (requires UI Draggables plugin)
okButton: property_dict['allDialog.OK.button.text'], // text for the OK button
cancelButton: property_dict['grid.Confirm.Delete.cancel'], // text for the Cancel button
deleteButton: property_dict['grid.Confirm.Delete.remove'], // text for the remove button
dialogClass: null, // if specified, this class will be applied to all dialogs
我看到在页面顶部,它表示可以通过访问脚本中的$ .alerts.propertyName来更改这些属性 - 问题是,似乎没有关于如何实际执行此操作的文档
任何jAlert忍者都可以帮助我:?
答案 0 :(得分:4)
你完全按照它的说法 - “在脚本中访问$ .alerts.propertyName”
更改确定按钮上的文字:
$.alerts.okButton = 'string literal or variable here';
更改取消按钮上的文字:
$.alerts.cancelButton = 'string literal or variable here';