JQ UI Dynamic Dilog Pop Up

by manoj

HTML

<script src="http://vitalets.github.com/x-editable/assets/mockjax/jquery.mockjax.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://vitalets.github.io/x-editable/assets/x-editable/jqueryui-editable/js/jqueryui-editable.js"></script>
<link rel="stylesheet" href="http://vitalets.github.io/x-editable/assets/x-editable/jqueryui-editable/css/jqueryui-editable.css">

JavaScript

$(function(){$('<div></div>').appendTo('body')
        .html('<div>' +
       '<span style="padding-left:4px;">Are you sure you want to delete this FDUAQ Attachment?</span>' + '</div>')
        .dialog({
            modal: true, title: 'Delete FDUAQ Attachment', zIndex: 10000, autoOpen: true,
            width: 'auto', resizable: false,
            buttons: {
                Yes: function () {
                    $.ajax({
                        url: TsaConnect.serviceBase + "FDUAQ/FDUAQ/DeleteAttachment",
                        type: 'POST',
                        dataType: 'json',
                        data: { id: attach.id },
                        success: function (status) {
                            if (status == "ok") {

                                self.fduattach.remove(attach);

                            }
                            else {
                                alert(status);
                            }
                        }

                    });

                    $(this).dialog("close");
                    return true;
                },
                No: function () {
                    $(this).dialog("close");
                    return false;
                }
            },
            close: function (event, ui) {
                $(this).remove();
                return false;
            }
        });
               });