Skip to content

Commit

Permalink
Merge pull request #10 from d3k4y/master
Browse files Browse the repository at this point in the history
fixed #8
  • Loading branch information
raiyankamal authored Sep 2, 2017
2 parents fdeac37 + 3b4d6ff commit 53735e9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions autoform-nouislider.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,30 @@ Template.afNoUiSlider.rendered = function () {
var setup = function(c){
var data = Template.currentData(); // get data reactively
var options = calculateOptions( data );
noUiSlider.create($s[0], options);
var sliderElem = $s[0];

if(sliderElem.noUiSlider) {
sliderElem.noUiSlider.updateOptions(options, true);
}
else {
noUiSlider.create(sliderElem, options);
}

if (c.firstRun) {
$s[0].noUiSlider.on('slide', function(){
sliderElem.noUiSlider.on('slide', function(){
// This is a trick to fool some logic in AutoForm that makes
// sure values have actually changed on whichever element
// emits a change event. Eventually AutoForm will give
// input types the control of indicating exactly when
// their value changes rather than relying on the change event
$s.parent()[0].value = JSON.stringify($s[0].noUiSlider.get());
$s.parent()[0].value = JSON.stringify(sliderElem.noUiSlider.get());
$s.parent().change();
$s.data('changed','true');
});
}

if( data.atts.noUiSlider_pipsOptions ){
$s[0].noUiSlider.pips(
sliderElem.noUiSlider.pips(
data.atts.noUiSlider_pipsOptions
);
}
Expand Down

0 comments on commit 53735e9

Please sign in to comment.