Simple question, but i'm stucked...
I want to set the plusmin on initialisation dependant on the defaultQty.
So is the defaultQty = 1 (of an other whole number like 2 or 3) then the plusmin has to be 1.
If it's not a whole integer (like 0.5) the plusmin has to be 0.1
define([
'ko',
'uiComponent'
], function (ko, Component) {
'use strict';
return Component.extend({
initialize: function () {
//initialize parent Component
this._super();
this.qty = ko.observable(this.defaultQty);
this.plusmin = 0.1;
},
decreaseQty: function() {
var newQty = this.qty() - this.plusmin;
if (newQty < this.defaultQty) {
newQty = this.defaultQty;
}
this.qty(newQty);
},
increaseQty: function() {
var newQty = this.qty() + this.plusmin;
this.qty(newQty);
}
});
});