jQuery UI Widgets Forums Lists ListBox option value

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 13 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    option value Posts
  • option value #1044

    DPolyakov
    Blocked

    Hello, it’s me again 🙂

    i load data from array and i need equivalent of attr “value” in option.
    i can`t use item.label because it on russian.

    what i must do?

    option value #1068

    Peter Stoev
    Keymaster

    Hi DPolyakov,

    Thank you for writing.

    The equivalent of the “value” attribute is the “value” property.

    The code below creates a data sources with label and value fields for each item.

                    var source = [
    { label: "Affogato", value: "value1" },
    { label: "Americano", value: "value2" },
    { label: "Bicerin", value: "value3" },
    { label: "Breve", value: "value4" },
    { label: "Liqueur coffee", value: "value5" },
    ];
    // Create a jqxListBox
    $("#jqxListBox").jqxListBox({ source: source, width: '200px', height: '250px'});

    Here’s how to retrieve the “value” and “text” of the selected item:

                   $('#jqxListBox').bind('select', function (event) {
    var args = event.args;
    var item = $('#jqxListBox').jqxListBox('getItem', args.index);
    // get value
    var value = item.value;
    // get text
    var text = item.label;
    });

    Hope this helps you.

    Please feel free to write us, if you have any further questions.

    Best Regards,
    Peter Stoev

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.