jquery 的dialog 總結

可以自己添加按鈕:

1. 想dialog 增加自己的方法,addbutton 和 removebutton

 

$.extend($.ui.dialog.prototype, {
        'addbutton': function(buttonName, func) {
                var buttons = this.element.dialog('option', 'buttons');
                buttons[buttonName] = func;
                this.element.dialog('option', 'buttons', buttons);
        }
});

$.extend($.ui.dialog.prototype, {
        'removebutton': function(buttonName) {
                var buttons = this.element.dialog('option', 'buttons');
                delete buttons[buttonName];
                this.element.dialog('option', 'buttons', buttons);
        }
});

Add it into into a JS file if you wish. Usage:
2. 使用
$('#MyDialog').dialog('removebutton', 'Old Button');
$('#MyDialog').dialog('addbutton', 'New Button', newButtonClickFunction);

function newButtonClickFunction() {
    alert('You clicked the new button!');
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章