2011-03-31 76 views
4

有沒有方法在jQuery UI對話框的兩個按鈕之間添加內容?用下面的代碼,我想在兩個按鈕之間寫入OR。這可能嗎?jQuery UI對話框添加內容

$("#dialog-delivery").dialog({ 
       bgiframe: true, 
       resizable: true, 
       height:350, 
       width:400, 
       modal: true, 
       buttons: { 
        "Continue": function() { 
         $(this).dialog("close"); 
         $(".option-separate").hide(); 
         $("#nonsubscribers").hide(); 
         $('<div class="radio-alert">Thank you for your selection</div>').appendTo('#subscribers'); 
         $("#change-subs").css('visibility','visible'); 
        }, 
        "Change to Non-Subscriber": function() { 
          $(this).dialog("close"); 
          $("#subscribers").hide(); 
          $(".option-separate").hide(); 
          $("#nonsubscribers").show(); 
          $("#change-nonsubs").css('visibility','visible'); 
         } 
       } 
    }); 

回答

5

It's a little hack-y, but have a look at this demo ->

相關的另外一個對話框打開處理器:

open: function() { 
    $('.ui-button-text:contains("Continue")') 
     .parent() 
     .after('<div class="button-divider">OR</div>'); 
} 

什麼這樣做:選擇一些特定文本的UI按鈕,後插入<div>。該類很重要,因爲您需要至少一個CSS樣式才能正確放置分隔符。下面是我使用的樣式:

.button-divider { 
    margin: .5em .2em .5em 0; 
    float: right; 
    padding: .2em 0 .3em 0; 
    width: auto; 
} 

最重要的部分是float:right;,因爲UI按鈕浮動,所以你的分離器還必須上浮,才能正確地放置。

+0

謝謝。這對於在按鈕集下面追加文本也非常有用。 – aglasser 2016-12-01 19:47:16

相關問題