簡體   English   中英

使用jAlerts動態更改按鈕文本

[英]Changing Button Text Dynamically with jAlerts

我在執行相對簡單的任務時遇到了麻煩。 我正在使用不再支持的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忍者可以幫助我嗎?

您完全按照它的意思進行操作-“在腳本中訪問$ .alerts.propertyName”

更改“確定”按鈕上的文本:

$.alerts.okButton = 'string literal or variable here';

更改取消按鈕上的文本:

$.alerts.cancelButton = 'string literal or variable here';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM