Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

sbeam
Copy link

@sbeam 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>';
 }});

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
@fnagel
Copy link
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
Copy link

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.

@fnagel
Copy link
Owner

fnagel commented Aug 30, 2012

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

Please test and give feedback!

@fnagel
Copy link
Owner

fnagel commented Oct 25, 2012

Any feedback on this issue?

@sbeam
Copy link
Author

sbeam commented Oct 25, 2012

seems fine
http://jsfiddle.net/sbeamox/GXtpC/743/

@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants