bootstrap-combobox icon indicating copy to clipboard operation
bootstrap-combobox copied to clipboard

placeholder attribute

Open Munawwar opened this issue 9 years ago • 4 comments

I see one has to use data-placeholder attribute to get placeholder working. Line 99:

this.options.placeholder = this.$source.attr('data-placeholder') || this.options.placeholder

Why not use placeholder attribute directly (without data- prefix)?

Munawwar avatar Jul 21 '15 16:07 Munawwar

An open pull request might solve this issue - the PR suggests simply looping through all attributes and filtering out the ones we don't want (like, presumably, style tags and so on) instead of selectively pulling in the ones we do want. That might fix this issue. However, I'm also not sure why they chose data- tag instead of simply using placeholder. Maybe because semantically that's more accurate?

wagedomain avatar Jan 18 '16 15:01 wagedomain

Bumped into this one today as well. I've fixed it by replacing the line with this:

this.options.placeholder = this.$source.attr('data-placeholder') || this.$source.attr('placeholder') || this.options.placeholder

@danielrutten I'd be inclined to switch the order of those checks - check the "real" attribute first, then the data attribute, and then fallback to the options value. Of course, there's also the question of, if all are set, which value has priority, especially if they differ (for whatever reason)?

tiesont avatar Sep 15 '17 02:09 tiesont

@tiesont I'm not sure either what the semantics would be if both are set with different values.

I chose this order so that, if both are set, the data-placeholder doesn't get overwritten by the placeholder value. This ensures backward compatibility, but I'm at a loss why anyone would use the data-placeholder attribute in any other situation, since it's not rendered.