seiyria / bootstrap-slider

A slider control for Bootstrap 3 & 4.
http://seiyria.github.io/bootstrap-slider/
Other
2.99k stars 1.14k forks source link

Proposed enhancement - tooltip formatter #837

Closed xavier-90 closed 6 years ago

xavier-90 commented 6 years ago

Usage scenario: Range slider and use of tooltip formatter , where a different format must be returned based on the handle. E.g. Low handle tooltip: “Lower limit n” High handle tooltip: “Upper limit n

Proposal: Change this.options.formatter (9 off) calls to include the value index as a second variable. e.g. Change this.options.formatter(this._state.value[1]) to… this.options.formatter(this._state.value[1], 1)

seiyria commented 6 years ago

You could already do this by checking which value is larger and formatting it differently based on that. This would be a more robust solution anyway as it doesn't rely on the position in the array for the handle.

xavier-90 commented 6 years ago

The main issue with your approach (apart from the inefficiencies and complexity introduced by having to rely on j queries to fetch additional info on changed states) is what if min value equals max value? I would also challenge on your take on reliability, the most reliable way to achieve this is for the formatter to indicate which limit is being adjusted so passing the index or if you prefer a reference to the context handle is the most reliable and possibly more efficient approach.

seiyria commented 6 years ago

I gave you a solution you could implement today because this project is mostly in maintenance mode.

xavier-90 commented 6 years ago

Ok, fair enough if no further development is planned. (this was not a bug report but a enhancement suggestion)