loopj / jquery-simple-slider

Unobtrusive numerical slider plugin for jQuery
194 stars 113 forks source link

The 'change' event is not called after dynamic loading of sliders #76

Open brightpixelstudio opened 9 years ago

brightpixelstudio commented 9 years ago

I have a page where I add a bunch of sliders via an Ajax call. I set the sliders settings by passing the options after they are inserted into the page. I then bind the sliders to the change event and it never gets called. Any ideas?

// add dynamic content
$("#weightsdiv").html(sliderContent);

// initialize sliders with settings
$(".sliderctl").simpleSlider({ range: '[1,100]', theme: 'volume', highlight: 'true', step: 1 });

// bind the onchange event
$(".sliderctl").on("slider:changed", function (event, data) {
        console.log("I have changed for the best!");
        var id = $(event.target).data("id");
        $("#" + id).html(data.value.toFixed(0) + "%");
});