Closed ramesh199764 closed 3 years ago
Changing the slider options like that in an object reference will not work.
It is probably easiest to move your condition check into the original formatter:
to: function (value) {
if (something) {
return Math.round(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
return value.toString();
},
Hi , can you explain that in detail.i need to do the check while initializing it.but the change is happening while changing a value .not while initializing it.can you pls explain it in detail.It would be really helpful for me.(Also ineed to apply that in which property-tooltips or format)
While initializing the slider i was rounding the value(using math.round).After that,based on certain condition(while changing something,calling function-event)) i need to remove the rounding off.thats the task. can you pls help me by giving certain tips to complete this.I would be great for me if it"s possible.
Simply put:
var condition = false;
noUiSlider.create({
...
format: {
to: function (value) {
if (condition) {
return Math.round(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
return value.toString();
},
...
}
...
});
function yourCallbackOrTrigger() {
condition = true;
}
It is not working as expected.It is not rounding off for intergers..... this is the code... format: { to: function (value) { if (integer) { return Math.round(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } return value.toString(); }, from: function (value) { if (integer) { return Math.round(value); } return value; } }, tooltips: { to: function (value) { if (integer) { return Math.round(value).toFixed().toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); }, from: function (value) { if (integer) { return Math.round(value).toFixed().toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } }
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
i need to update the slider values based on if condition.for example for one case the slider should not round its values.for another case the slider should round its values.that is the expected result.while initializing slider iam rounding it .After that while callling a function i need to remove that round off .i have done it.but its not reflecting.pls help me on this.(the framework is angular) HTML- <nouislider class="sumAssuredSlidercont slider-blue" [step]="1" [min]="policyTermNouisliderMin" [max]="policyTermNouisliderMax" [config]="policyconfig" name="groupquotesumAssured3" [(ngModel)]="loanDetailsData.policyTerm" (change)="checkSliderValue(policyTermNouisliderMin, policyTermNouisliderMax, 'policyTerm')">
TS File- public policyconfig: any = { format: { to: function (value) { return Math.round(value); }, from: function (value) { return Math.round(value); } }, tooltips: { to: function (value) { return Math.round(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); }, from: function (value) { return Math.round(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } } };
based on certain condtion i update the slider like this-> this.policyconfig = { format: { to: function (value) { return value.toString(); }, from: function (value) { return value; } }, tooltips: { to: function (value) { return value.toString(); }, from: function (value) { return value; } }, }; can any one helpme to solve this????