將字符串傳遞給jquery對話框以成為按鈕的名稱

[英]pass string to jquery dialog to become name of the button


For the purpose of globalization I need to translate buttons in jquery dialog, but when I try to pass variable I don't get value of variable, just name of it.

出於全球化的目的,我需要在jquery對話框中翻譯按鈕,但是當我嘗試傳遞變量時,我沒有得到變量的值,只是它的名稱。

    var RemoveDialogButton = "@FriendsNamesNS.FriendsNames.Remove";
    var CancelDialogButton = "@FriendsNamesNS.FriendsNames.Cancel";

   //alert(RemoveDialogButton);

   $( "#dialog-confirm" ).dialog({
        autoOpen: false,
        resizable: false,
        height:190,
        modal: true,
        buttons: {
        RemoveDialogButton: function() {
             $( this ).dialog( "close" );
            $('#yesno').click();
            return true;
        },
        CancelDialogButton: function() {
        $( this ).dialog( "close" );
        }
      }
    });

2 个解决方案

#1


1  

RemoveDialogButton: {
      click: function() {
          $( this ).dialog( "close" );
          $('#yesno').click();
          return true;
      },
      text: RemoveDialogButton
}

#2


0  

 var buttons= {};
 buttons[your text] = function() { ....};


 $('.selector').dialog({      
   buttons: my_buttons 
  });

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/02/28/729fa8296db732ebfc596d29d2c3736d.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com