Closed evertslagter closed 13 years ago
Hi,
Yeah, it looks like I forgot to update the docs for that option. It's very similar to optionFormat, but here are the differences.
optionFormat takes an <option>
element and produces markup that will appear when you open the dropdown.
displayFormat takes an <option>
element and produces markup that will appear in the piece of the selectbox that is always visible.
If displayFormat is not set, it uses optionFormat instead.
Hope that helps. I'll get that added to the documentation...
Thnx, that helps.
If I want to add a css class to my options in the items list text and to my display text. I can use optionsFormat.
<option value="1" selected="selected" class="classname">Option 1</option>
<option value="2" class="classnmae2">Option 2</option>
</select>
optionFormat: function() {
if($(this).attr('class')) {
return $("<div>").addClass($(this).attr("class")).text($(this).text());
}
return $(this).text();
}
But then I get [Object Object] in the display text div, what am I doing wrong, it works for the options. :)
Ah, the problem was on line 221 of jquery.sb.js. There it was expecting a simple string and it was being passed a jQuery object, which is why it was showing [Object object]. It didn't know to serialize it.
I just pushed an update that I think should fix your issue. Give it a try and let me know if it works.
Hi, yes that works, thank you for the fast support!
Hi, you are using a displayFormat option in your examples. but it doesn't seem to be in the README.md. Does the option alter the display text element and options text element or just the display text element? How does it work?