2013-01-01 58 views

回答

1

可以使用create事件添加按鈕。這是一個簡單的方法,以確保按鈕不會被添加多次

var newBtn = '<a href="#" class="myDialogBtn"><span class="ui-icon ui-icon-alert"></span></a>'; 

$('#dialog').dialog({ 
    title: 'Test Dialog', 
    create: function() { 
     $(this).prev('.ui-dialog-titlebar').find('.ui-dialog-title').after(newBtn) 
    } 
}) 

INSPEC在瀏覽器控制檯現有的按鈕複製額外的CSS需要

DEMO:http://jsfiddle.net/eh4Aj/

API參考: http://api.jqueryui.com/dialog/#event-create

1

請試試這個,添加下面的代碼給打開jQuery用戶界面對話框的功能

$(".ui-dialog-titlebar").append("<input type=\"button\" id=\"yourID\" value=\"My Custom\">"); 
1

可以通過插入按鈕使用jQuery before功能自定義jQuery UI的對話框,

jQuery代碼:

<script language="javascript" type="text/javascript"> 

$(document).ready(function() { 
    $('#trigger').click(function(){ 
     $("#dialog").dialog(); 
     $(".ui-dialog-titlebar-close").before('<input name="newBtn" id="newBtn" type="button" style="float:right;" value="BUTTON"/>'); 
    }); 
}); 
</script> 

HTML代碼:

<input name="trigger" id="trigger" type="text" /> 
<div id="dialog" style="display:none"> 
    <div> 
     Content 
    </div> 
</div>