views:

29

answers:

2

Hi. 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>
+1  A: 
$('#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"); } } 


        });
Phil.Wheeler
Please See My question again. i have error yet
shaahin
i did add your code but i have syntax error!
shaahin
Ah. I've omitted a comma. I've updated the example.
Phil.Wheeler
+2  A: 

Here is an example

add this to your function:

buttons: {
                OK: function() { //submit
                    $( this ).dialog( "close" );
                },
                Cancel: function() { //cancel
                    $( this ).dialog( "close" );
                }
            }

So you get

    $('#msgBox').dialog({


                autoResize: true,
                show: "clip",
                hide: "clip",
                height: 'auto',
                width: 'auto',
                autoOpen: false,
                modal: true,
                position: 'center',
                draggable: false,
                buttons: {
                OK: function() { //ok
                    $( this ).dialog( "close" );
                },
                Cancel: function() { //cancel
                    $( this ).dialog( "close" );
                }
            }
                open: function (type, data) {
                    $(this).parent().appendTo("form");
                }


            });
Tim