Нужно добавить выбранные поля в jsery MsgBox - PullRequest
0 голосов
/ 19 мая 2011

Мне нужно добавить поля выбора в MsgBox с помощью jQuery. Кто-нибудь знает как?

if (input.type == 'checkbox')
{
    iLabel = input.label ? '<label class="' + this.options.name + '-label">' : '';
    fLabel = input.label ? input.label + '</label>' : '';
    input.value = input.value === undefined ? '1' : input.value;
    iName  = input.name === undefined ? this.options.name + '-label-' + i : input.name;
    this.esqueleto.inputs.append($(iLabel + '<input type="' + input.type + 
        '" style="display: inline; width: auto;" name="' + iName + '" value="' + 
        input.value + '" autocomplete="off"/>' + fLabel));
}

Я изменил его для выбора полей, но он не работает при передаче PHP> jQuery и наоборот. Может ли кто-нибудь помочь?

1 Ответ

1 голос
/ 16 августа 2011
if (input.type == 'checkbox') {
    iLabel = input.label ? '<label class="' + this.options.name + '-label">': '';
    fLabel = input.label ? input.label + '</label>': '';
    input.value = input.value === undefined ? '1': input.value;
    iName = input.name === undefined ? this.options.name + '-label-' + i: input.name;
    this.esqueleto.inputs.append($(iLabel + '<input type="' + input.type + '" style="display:inline; width:auto;" name="' + iName + '" value="' + input.value + '" autocomplete="off"/> ' + fLabel))
} else if ( input.type == 'select' ) {
    iLabel = input.label ? '<label class="' + this.options.name + '-label">' + input.label: '';
    fLabel = input.label ? '</label>': '';
    input.value = input.value === undefined ? '': input.value;
    iName = input.name === undefined ? this.options.name + '-select-' + i: input.name;
    this.esqueleto.inputs.append($(iLabel + '<select name="' + iName + '"></select>' + fLabel));
    $.each(input.options, $.proxy(function(ip, ap) {
        ap.value = ap.value === undefined ? '': ap.value;
        iName = ap.name === undefined ? this.options.name + '-option-' + ip: ap.name;
        $('select[name=' + input.name + ']').append($('<option value="' + ap.value + '">' + ap.label + '</option>'))
    }, this));
}

inputs  : [
    { type: "select", name: "select", label: "select:", options: [{ label: "option1", value: "option1" },{ label: "option2", value: "option2" }] }
]

Найдите эту строку в коде Javascript:

this.close(this.toArguments($('input', this.esqueleto.inputs)))

и добавьте , select в качестве селектора jQuery, чтобы получить:

this.close(this.toArguments($('input, select', this.esqueleto.inputs)))

и CSS:

.jquery-msgbox-inputs select
{
    display: block;
    padding: 3px 2px;
    border: 1px solid #dddddd;
    margin: 3px 0 6px 0;
    width: 97%;
}
...