I want to make <select> replacement with custom text formatting using jQuery UI Selectmenu.
Third and fifth selects in this fiddle are good examples of what I am trying to achieve:
http://jsfiddle.net/fnagel/GXtpC/
In the fiddle, there is defined function addressFormatting(), which takes the original option text and returns html output which will be used for rendering the selectmenu. This function is passed as a callback in the selectmenu initialization:
$('select').selectmenu({
format: addressFormatting
});
I am using jQuery UI Selectmenu 1.11.4. The problem is that the format callback option is not present in this version.
This is a portion of code from jQuery UI Selectmenu version 1.5.0pre, used in the provided fiddle:
$.widget("ui.selectmenu", {
options: {
appendTo: "body",
typeAhead: 1000,
style: 'dropdown',
positionOptions: null,
width: null,
menuWidth: null,
handleWidth: 26,
maxHeight: null,
icons: null,
format: null, // <<<<<<<<<<<< FORMAT OPTION IS PRESENT <<<<<<<<<<<<
escapeHtml: false,
bgImage: function() {}
},
And this is the portion of code from newer version that I am using:
var selectmenu = $.widget( "ui.selectmenu", {
version: "1.11.4",
defaultElement: "<select>",
options: {
appendTo: null,
disabled: null,
icons: {
button: "ui-icon-triangle-1-s"
},
position: {
my: "left top",
at: "left bottom",
collision: "none"
},
width: null,
// callbacks
change: null,
close: null,
focus: null,
open: null,
select: null
},
format option is not present here, and using it in the initialization has no effect.
In the API documentation, there is _renderItem() method, whose name suggest it could be used to add custom formatting to the select, but it has private scope, so I can't use it from outside of the widget. There is also public create() method, but I am not sure if I can or if I should use it to change the structure of created selectmenu.