2010-08-23 75 views
0

我需要更改在jQuery UI對話框模式中創建的輸入按鈕的值,以便以用戶的語言顯示它們。jQuery UI模式輸入按鈕值

我不明白該怎麼做。

var $dialog = $('<div><div style="padding:10px;text-align:left">' 
     +'New name' 
     +'</div>' 
     +'<div style="padding:0 10px 10px 10px;text-align:left;">' 
     +'<input id="dialogInput" style="width:370px" type="text"/>' 
     +'</div></div>') 
      .dialog({ 
     modal:  true, 
     title:  'title', 
     width:  400, 
     buttons: { 
      **'Ok'**: function() { 
       $(this).dialog('close'); 
       return true; 
       }, 
      **'Cancel'**: function() { 
       $(this).dialog('close'); 
       return true; 
       } 
      } 
    }); 

謝謝!

回答

0

找到了解決辦法

var $dialog = $('<div><div style="padding:10px;text-align:left">' 
    +'New name' 
    +'</div>' 
    +'<div style="padding:0 10px 10px 10px;text-align:left;">' 
    +'<input id="dialogInput" style="width:370px" type="text"/>' 
    +'</div></div>') 
     .dialog({ 
    modal:  true, 
    title:  'title', 
    width:  400, 
    buttons: { 
     **'Ok'**: function() { 
      $(this).dialog('close'); 
      return true; 
      }, 
     **'Cancel'**: function() { 
      $(this).dialog('close'); 
      return true; 
      } 
     } 
}); 

// i was missing the parent() traversing needed since the form is embedded in the dialog popup 
$dialog.parent().find('button:contains("Ok")').text('New Ok text'); 
$dialog.parent().find('button:contains("Cancel")').text('New cancel text'); 
+0

我往往只是把我的對話框中的標記,但添加顯示:隱藏;到CSS,所以它只在需要時顯示,而不是在腳本中嵌入標記。 – 2010-08-24 13:41:35

+0

不能以這種形式存在標記,因爲此功能(對話)以多種不同形式即時調用。 在這裏它被簡化了,但在真實的應用程序中,我有不同的標記對話框。我是來自Prototype的jQuery的新手,並且移植了一整套應用程序。 – velo 2010-08-24 17:29:51