在jquery对话框中添加选项字段

时间:2014-08-23 17:01:16

标签: jquery dialog

我正在使用AJAX调用来获取数据以编辑我的表单

之后我在jQuery对话框中加载表单并设置字段值

但是我无法添加选择输入类型的选项字段(无法在选择菜单中获取列表我使用了选择-jquery)

这是我的代码

function edit(intvalue) {
    aucid = intvalue;

    $.ajax({
        type: 'POST', // define the type of HTTP verb we want to use (POST for our form)
        url: 'controller/controller_remateedit.php', // the url where we want to POST
        data: {
            remate_id: aucid
        }, // our data object
        dataType: 'json', // what type of data do we expect back from the server
        encode: true,

        success: function (data) {
            //what to do in success

            $("#dialog-message").dialog({
                modal: true,
                draggable: false,
                resizable: false,
                show: 'blind',
                hide: 'blind',
                width: 900,
                dialogClass: 'ui-dialog',


                create: function (event, ui) {
                    $("#base").val(data.remate_data.base);

                    var o = new Option("option text", "value");

                    $(o).html("option text");
                    $("#property").append(o);
                    $("#content").jqteVal(data.remate_data.edicto);
                }
            });
        }
    });
}

1 个答案:

答案 0 :(得分:1)

试试这个: 你需要改变

    var o = new Option("1", "value");
    $(o).html("option text");
    $("#property").append($(o));

请参阅Fiddle

相关问题