enhance `format` option by passing entire option element to function #242

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

sbeam commented Jul 5, 2012

instead of just passing the text, give the formatter function a reference to the
entire option element during construction.

Still passing opt.text() as the first argument to preserve backwards compatibility, although this is now superfluous it does not seem worth it to break existing apps.

An example of why this is needed is in my use case which uses data- attributes from the original option elements to make the options look fancy:

$('#product_options select.calculatable').selectmenu({format : function(text, opt) {
            return opt.text()
                   + '<span class="price">'
                   + format_price($(opt).data('adder'))
                   + '</span>';
 }});
pass entire option to format function
instead of just passing the text, give formatter a reference to the
entire <option> element. Still passing opt.text() as the first argument
to preserve back-compat
Owner

fnagel commented Jul 11, 2012

I'm pretty busy right now and need to fix the v1.3 (see milestone filter) bugs but I will take a look asap.

Related issues: #199 and #162

jakov commented Jul 21, 2012

+1

In my case it's a multilingual dropdown where I want to read out the language code from the value property.

Owner

fnagel commented Aug 30, 2012

Please note: this issue seems to be solved within this pull request: #257

Please test and give feedback!

Owner

fnagel commented Oct 25, 2012

Any feedback on this issue?

@sbeam sbeam closed this Oct 25, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment