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

Replace placeholder text with selected list item text on submit? #3

Closed
welly opened this issue Jul 6, 2014 · 8 comments
Closed

Replace placeholder text with selected list item text on submit? #3

welly opened this issue Jul 6, 2014 · 8 comments

Comments

@welly
Copy link

welly commented Jul 6, 2014

Fantastic widget! Thank you so much for your work on this.

I have a request, unless the functionality is there and I'm not using it correctly! When I use placeholder text, I've noticed when you submit a form, the placeholder text is showing in the select boxes rather than the selectors showing the previously selected list item. Is there a way of doing this?

Thanks!

@vestman
Copy link
Owner

vestman commented Jul 7, 2014

Could you give me an example?

Edit: Thanks, I'm glad you like it!

@PawelGIX
Copy link

SOD don't display selected option on page load if there is placeholder configured. Maybe you should add empty option on beginning of select input in this scenario (but not displayed in sod) - this reflects first empty state.

@vestman
Copy link
Owner

vestman commented Oct 11, 2014

Well, @welly, it only took me 3 months. But after reading the comment from @PawelGIX I added a second placeholder option that will use the first <option> in the select as the placeholder. Don't know if this is what you're looking for, @welly.

@bryannielsen
Copy link

I think I'm seeing this issue too, if you have a placeholder set (I'm using data-placeholder) and you load a element that already has a "selected" option, the placeholder is displayed instead of the selected option's value. I'm looking to see if I can figure out a workaround right now.

@vestman
Copy link
Owner

vestman commented Oct 24, 2014

@bryannielsen Thanks for the input. The thing is that a native <select> always have a "selected" <option>, even if the user haven't made a selection or there's not an <option selected> specified. I guess the first sentence - "If you feel like adding a placeholder that's displayed before anything is selected" - in the description of the placeholder alt.1 is a bit misleading.

As I wrote in the comment above I added a second placeholder setting that fixes this issue. But then you need to prepend your <select>with an <option> that should be used as the placeholder.

In this fiddle you'll see an example of how both settings works. The third one is using the placeholder alt.1 setting and if you fire up the console you'll see that the first option is the one selected.

@vestman
Copy link
Owner

vestman commented Oct 25, 2014

I'm closing this issue for now. Feel free to re-open if you don't feel that the second placeholder setting does the trick.

@vestman vestman closed this as completed Oct 25, 2014
@bryannielsen
Copy link

@vestman thanks! This looks perfect. Sorry I read the description for the new placeholder option but it wasn't clear to me that it would fix this issue. Looking at your fiddle and your description above I think this should solve the problem.

Thanks for the quick response and the awesome plugin!

@vestman
Copy link
Owner

vestman commented Oct 27, 2014

No problem, @bryannielsen, just let me know if you have any other questions. I'm glad you like the plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants