Диалог Да / Нет при отмене загрузки файла - PullRequest
0 голосов
/ 07 марта 2012

Я использую Uploadify для загрузки файла и хочу показать диалоговое окно Да / Нет, когда пользователь отменяет загрузку.Я попробовал следующее, но он не отображает диалоговое окно.Любая идея, что не так с кодом ниже?

'onCancel': function (event, ID, fileObj, data) {                   
                var x = "Are you sure you want to take this action";
                $('<div>' + x + '</div>').dialog({
                    resizable: false,
                    autoOpen: true,
                    buttons: {
                        "Yes": function () {
                            alert('action taken');
                            $(this).dialog("close");
                        },
                        Cancel: function () {
                            $(this).dialog("close");
                        }
                    }
                });

Любые предложения / указатели будут высоко оценены!

Ответы [ 4 ]

0 голосов
/ 14 октября 2012
 <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script type="text/javascript">
    $(document).ready(function () {
        $('#cmdShowDialog').click(function (event) {
            event.preventDefault();
            var $dialog = $('<div>Dynamic Dialog with Buttons.</div>')
            .dialog
            ({
                title: 'Cancel',
                width: 300,
                height: 200,
                buttons:
                [{
                    text: "Ok",
                    click: function () {
                        $dialog.dialog('close');
                    }
                },
                {
                    text: "Cancel",
                    click: function () {
                        $dialog.dialog('close');
                    }
                }]
            });
        });
    });
</script>


 <div>
    <asp:Button ID="cmdShowDialog" runat="server" Text="Show Dialog" />
</div>

Попробуйте это будет работать наверняка

0 голосов
/ 07 марта 2012

вместо этого попробуйте следующее:

buttons: [{
    text: 'Yes',
    click: function() {
        alert('action taken');
        $(this).dialog("close");  
    }},{
    text: 'Cancel',
    click: function() {
        $(this).dialog("close")   
    }}]
0 голосов
/ 07 марта 2012

Добавляете ли вы только что созданный div в body HTML-кода?

Попробуйте:

onCancel: function (event, ID, fileObj, data) {
    var x = "Are you sure you want to take this action";
    var dlg = $('<div />').attr('id', 'RUSure').text(x).dialog({
        autoOpen: true, //Make sure it opens automatically.
        resizable: false,
        buttons: {
            "Yes": function () {
                alert('action taken');
                $(this).dialog("close");
            },
            "Cancel": function () {
                $(this).dialog("close");
            }
        }
    })
    $('body').append(dlg);
    $('#RUSure').dialog('open');
    //dlg.dialog('open'); //or this, maybe?
0 голосов
/ 07 марта 2012

Попробуйте это:

var onCancel = function (event, ID, fileObj, data) {                   
            var x = "Are you sure you want to take this action";
            $('<div>' + x + '</div>').dialog({
                resizable: false,
                buttons: {
                    "Yes": function () {
                        alert('action taken');
                        $(this).dialog("close");
                    },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                }
            });
         }
...