jQuery UI Widgets Forums Lists ListBox Data attribs on select options?

This topic contains 2 replies, has 2 voices, and was last updated by  carpii 7 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Data attribs on select options? #89646

    carpii
    Participant

    I have a native HTML select with options like this…

    
    <select id="fontpicker">
      <option data-fontid="0" data-family="'Lucida Sans Unicode', 'Lucida Grande', sans-serif, 'Segoe UI Emoji'">Lucida (default)</option>
      <option data-fontid="1" data-family="Georgia, serif, 'Segoe UI Emoji'">Georgia</option>
    </select>
    

    I want to replicate this somehow using jqxDropDownList

    I have tried just creating it directly from the select via $(“#fontpicker”).jqxDropDownList(etc), but it doesn’t seem to copy the data attribs in any way. Thats fine, I didn’t really expect it to.

    But is there a way I can assign and retrieve .data() attribs on the individual jqxDropDownList options?

    Thanks

    Data attribs on select options? #89668

    Christopher
    Participant

    Hi carpii,

    If you create a jqxDropDownList from the HTML select tag like in this demo: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdropdownlist/dropdownlist-from-select.htm?light , it will be possible to access the data attributes with the data() method like so:

    $('#fontpicker').data().jqxDropDownList.element[0].dataset.

    “$(‘#fontpicker’).data().jqxDropDownList” contains the attribute “element” which returns an array of all the options of the select element.

    Best Regards,
    Christopher

    jQWidgets Team
    http://www.jqwidgets.com

    Data attribs on select options? #89694

    carpii
    Participant

    Thankyou, thats very useful

    This was the last problem I needed to solve before buying a license 🙂

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

You must be logged in to reply to this topic.