选择值后显示消息框

Displaying a message box after selecting value

我想在为特定文本字段选择 ajax 自动完成值时显示消息框。为此,我正在使用 jquery-confirm js 库。这是我的代码。

                    select: function( event, ui ) {
                        console.log( ui.item.value );
                        nic= ui.item.value;
                        $("#msgbox").open();
                        return false;
                    }

.

    $("#msgbox").confirm({
        title: 'Entry Found',
        content: 'msg',
        lazyOpen:true,
        buttons: {
            confirm: function () {
                $.alert('Confirmed!');
            },
            cancel: function () {
                $.alert('Canceled!');
            },

ps:我对 js 和这些 jquery 东西很陌生。:)

试试这个。而不是 'confirm' 使用 'dialog'。在 'select'.

中像这样调用
$("#msgbox").dialog("open");

$("#msgbox").dialog({
    title: 'Entry Found',
    content: 'msg',
    autoOpen: false,
    modal: true,
    lazyOpen:true,
    buttons: {
        confirm: function () {
            alert('Confirmed!');},
        cancel: function () {
            alert('Canceled!');}
}
});

好的我发现了问题,select应该在jquery之外source,这里是完整的代码;

$("#nic").autocomplete({
            minLength:5,
            source : function(request, response) {
                $.ajax({
                    url: "ajaxautocomplete.html",
                    type: "Post",
                    data:JSON.stringify({"nic": request.term}),
                    contentType: "application/json",
                    dataType: "json",
                    success : function(data) {
                        response($.map(data.patient, function (patient) {
                            return{
                                label: patient.nic,
                                id: patient.id,
                            }
                        }))
                    }
                });
            },

            select: function( event, ui ) {
               //msg confirm box
                return true
            }
        });

对话框不工作,我用了jquery-确认框。