I'm trying to build a class that automates the instantiation of a jquery ui slider.
I can already instantiate the sliders, get them running etc.
But when i'm binding the slide event I run into the problem that this is now the event.
I've made a var _self = this; to resolve this, but that gets overwritten by every instance of the class.
The class:
$(function(window){
function WoningSelector(slider_id, min_id, max_id, step, min, max){
this.initialize(slider_id, min_id, max_id, step, min, max);
}
WoningSelector.prototype = {};
var _self;
// Constructor
WoningSelector.prototype.initialize = function(slider_id, min_id, max_id, step, min, max){
this.slider = $('#' + slider_id);
this.min = $('#' + min_id);
this.max = $('#' + max_id);
this.iMin = min;
this.iMax = max;
this.step = step;
_self = this;
_self.slider.slider({
range: true,
step: this.step,
min: this.iMin,
max: this.iMax,
values: [(this.iMin + (this.step * 4)), (this.iMax - (this.step * 4))],
slide: this.slide
});
_self.min.text(this.iMin + (this.step * 4));
_self.max.text(this.iMax - (this.step * 4));
};
// Slide event handler
WoningSelector.prototype.slide = function(event, ui){
_self.min.text(ui.values[0]);
_self.max.text(ui.values[1]);
};
window.WoningSelector = WoningSelector;
}(window));
slide: this.slide.bind(this)?