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

Attempt to use empty <option> element as 'placeholder' followed by 'placeholder' attribute. #69

Merged

Conversation

danielsokolowski
Copy link

Select's placeholders based on empty '<option value=””>placeholder</a>' convention are now used , but if possible the current default behaviour to use the 'placeholder' attribute is used. This plays nicer with forms generated as per the convention 'placeholder label option': http://dev.w3.org/html5/spec-preview/the-select-element.html. Also modified '.gitignore' to skip WebDAV cache/control files.

…>' convention are now used as the 'placeholder' text in the widget then fallowed the current behaviour to use the 'placeholder' attribute. This plays nicer with forms generated as per the convention 'placeholder label option': http://dev.w3.org/html5/spec-preview/the-select-element.html. Also modified '.gitignore' to skip WebDAV cache/control files.
@wmartins
Copy link
Contributor

Nice!

brianreavis added a commit that referenced this pull request Aug 13, 2013
@brianreavis brianreavis merged commit 8116ce9 into selectize:master Aug 13, 2013
o0x2a added a commit to o0x2a/jquery-placeholder that referenced this pull request Nov 13, 2013
When using [selectize](https://github.com/brianreavis/selectize.js) alongside jquery.placeholder, it adds the string 'undefined' when clicking on a selected value to change it. This is caused because the placeholder is set with an [empty option inside select](http://dev.w3.org/html5/spec-preview/the-select-element.html), then [selectize](selectize/selectize.js#69) turn this to an `input` element and set the proper `placeholder` attribute. It means an unnecessary placeholder event has been fired on an element which expected to have placeholder. This change fix this issue by checking if the value of`placeholder` attribute is valid before adding it to the `input` element. This good be an idea to implement placeholder support for `select` elements as it is conformed with [w3c](http://dev.w3.org/html5/spec-preview/the-select-element.html).
@@ -2575,7 +2575,8 @@
var $input = $(this);
var tag_name = $input[0].tagName.toLowerCase();
var settings_element = {
'placeholder' : $input.attr('placeholder'),
'placeholder' : $input.children('option[value=""]').text() || $input.attr('placeholder'),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason that the empty valued option should take precedence over the placeholder attribute? It seems like right now if you want to have an option with the empty string as a value, it is impossible. If the placeholder took precedence, then you could have an empty valued option by setting the placeholder to something else. Could this line be changed to

'placeholder' : $input.attr('placeholder') || $input.children('option[value=""]').text(),

without too much trouble?

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

Successfully merging this pull request may close these issues.

None yet

4 participants