Comments (4)
Since WHATWG has abandoned the proposal for a multiple
attribute for <input type="range">
, I suspect @LeaVerou has understandably lost interest in maintaining this. However, a workaround is pretty easy.
The problem is that when you add an event listener to your <input>
, it isn't automatically added to the second handle, which is rendered by a separate, generated "ghost" <input>
. The solution is to manually bind your event listener to that element. I've done it like this:
function handleChange() {
console.log('Range is %s to %s', this.valueLow, this.valueHigh);
}
const input = document.querySelector('input[type=range]');
input.addEventListener('input', handleChange);
input.nextElementSibling.addEventListener('input', handleChange.bind(input));
You can see it in action in this Stack Overflow answer. You must ensure that this code runs after multiselect loads, since it depends on input.nextElementSibling
being the "ghost" input.
from multirange.
I fixed this by making the ghost change event trigger change on the original:
jQuery example but the same should be possible in pure JS:
$(document).on('change', 'input[type=range].multirange.original', function() {
console.log(this.valueLow + ' - ' + this.valueHigh);
});
$(document).on('change', 'input[type=range].multirange.ghost', function() {
$('input[type=range].original', $(this).parent()).trigger('change');
});
from multirange.
I have the same problem. Any workarounds?
from multirange.
Hello,
The issue is related to the clone of node. the node use the same ID.
To resolve this issue you need to update the code and and add a suffix to the second ID.
After this line:
var ghost = input.cloneNode();
Please add:
ghost.id=ghost.id+"@clone" ;// HK update to avoid Id conflict
To trigger events on both sliders:
use in the html:
first slider Id= ranger@filter@dates
second slider ID = ranger@filter@dates@clone
var processSlider = function () {
console.log('Triggered!!')
}
window.onload = function(){
document.getElementById('ranger@filter@dates').oninput=processSlider
document.getElementById('ranger@filter@dates@clone').oninput=processSlider
}
from multirange.
Related Issues (20)
- ghost.value returns single instead of array HOT 1
- The maths on this is
- The maths on this is
- The maths on this is
- documentation not clear HOT 1
- Can't find documentation HOT 1
- Rotating the multirange input causes distortion, if not total breakage
- Missing fallback with 2 sliders
- glitch when absolute positioning changes box width HOT 4
- Removed HOT 3
- Removed HOT 1
- Removed HOT 2
- Removed HOT 1
- Issue loading plugin?
- "multiple" attribute not part of HTML Living Spec (as of 31 July 2016) HOT 4
- "module.exports = multirange" declaration causes TypeError with Vue.js
- In chrome browser the color left to the left handle looks wrong HOT 2
- Move both handles when dragging the track.
- CDN, package.json, CSS Variables free HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multirange.