Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add button to jquery ui dialog

I can not add button to this jquery ui dialog. if possible please give me an example . thanks.

<script type="text/javascript">
    $(document).ready(function () {
        //setup new person dialog
        $('#dialog2').dialog({
            autoResize: true,
            show: "clip",
            hide: "clip",
            height: 'auto',
            width: '1000',
            autoOpen: false,
            modal: true,
            position: 'top',
            draggable: false,
            title: "انتخاب درخواست",
            open: function (type, data) {
                $(this).parent().appendTo("form");
            }
        });

        $('#viewfaktor').dialog({
            autoResize: true,
            show: "clip",
            hide: "clip",
            height: 'auto',
            width: '1000',
            autoOpen: false,
            modal: true,
            position: 'top',
            draggable: true,
            title: "مشاهده صورت ریز",
            open: function (type, data) {
                $(this).parent().appendTo("form");
            }
        });


        $('#msgBox').dialog({


            autoResize: true,
            show: "clip",
            hide: "clip",
            height: 'auto',
            width: 'auto',
            autoOpen: false,
            modal: true,
            position: 'center',
            draggable: false,



            open: function (type, data) {
                $(this).parent().appendTo("form");
            }


        });



    });

    function showDialog(id) {
        $('#' + id).dialog("open");
    }

    function closeDialog(id) {
        $('#' + id).dialog("destroy");
    }



</script>
like image 668
Shahin Avatar asked Oct 27 '10 09:10

Shahin


People also ask

How do you check if jquery dialog is initialized?

dialog( { ... } ); Then check for the class when needed: if ($("selector"). hasClass("initialized")) { ... }


2 Answers

Sometimes you want to add the buttons dynamically after the dialog is created too. See my answer at the question Add a button to a dialog box dynamically

var mydialog = ... result of jqueryui .dialog()
var buttons = mydialog.dialog("option", "buttons"); // getter
$.extend(buttons, { foo: function () { alert('foo'); } });
mydialog.dialog("option", "buttons", buttons); // setter
like image 149
JJS Avatar answered Oct 14 '22 18:10

JJS


$('#msgBox').dialog({
    autoResize: true,
    show: "clip",
    hide: "clip",
    height: 'auto',
    width: 'auto',
    autoOpen: false,
    modal: true,
    position: 'center',
    draggable: false,

    open: function (type, data) {
        $(this).parent().appendTo("form");
    },

    buttons: { "OK": function() { $(this).dialog("close"); } } 
});
like image 41
Phil.Wheeler Avatar answered Oct 14 '22 18:10

Phil.Wheeler