如何关注javascripts对话框'确定'按钮

时间:2016-08-12 05:35:26

标签: javascript jquery

 $(document).ready(function () {
            var dlg = $("#divIssAgent").dialog({
                modal: true,
                bgiframe: true,
                autoOpen: false,
                height: 142,
                width: 560,
                draggable: true,
                resizeable: false,
                buttons: {                       
                    Ok: function () {                        
                        $(this).dialog('close');
                        $('.ui-widget-overlay').attr("style", "position: absolute;");
                        $("#ctl00_hldPage_txtAWBPrefix").focus();
                    },

                },
                open: function (type, data) {
                    alert($(this).parents('.ui-dialog-buttonpane button:eq(0)').text());
                    var test=$(this).parents('.ui-dialog-buttonpane button:eq(0)').text();
                    $(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
                    alert("hello");

                    $(this).parent().appendTo($("form:first"));
                    $('.ui-widget-overlay').attr("style", "position: fixed; z-index: 1001");
                    //$(this).focus();
                }

            });
            dlg.parent().appendTo($("form:first")); 
            $('.ui-dialog-titlebar-close').css("display", "none");
            $('#divIssAgent').dialog('open');
        });

1 个答案:

答案 0 :(得分:0)

您可以将类添加到按钮,文本为“OK” 如下:

buttons: {

**"OK": {
  class: 'OK'
}**,

Ok: function() {     
  $(this).dialog('close');
  $('.ui-widget-overlay').attr("style", "position: absolute;");
  $("#ctl00_hldPage_txtAWBPrefix").focus();
}

}

您可以在

之后添加以下内容

$( '#divIssAgent')对话框( '开放');

如下:

$('#divIssAgent').dialog('open');

$(".ui-dialog-button ok").focus();