From a01606fedba33143ccf7a94fb60b154cc44b4cde Mon Sep 17 00:00:00 2001 From: parag00991 Date: Sat, 19 Mar 2016 04:51:15 +0530 Subject: [PATCH] no more empty payoff after erasing its value --- html/js/tree/Payoff.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/html/js/tree/Payoff.js b/html/js/tree/Payoff.js index a4614a3..4ee1d46 100644 --- a/html/js/tree/Payoff.js +++ b/html/js/tree/Payoff.js @@ -39,9 +39,8 @@ GTE.TREE = (function(parentModule) { var text = this.getCleanedText(); if (text === "") { window.alert("Payoff should not be empty."); - } else { - thisPayoff.changeText(text); } + thisPayoff.changeText(text); }); }; @@ -50,6 +49,8 @@ GTE.TREE = (function(parentModule) { * @param {String} text New payoff's text */ Payoff.prototype.changeText = function(text) { + //Check if it's empty or not + if(text !== "") { // Remove leading 0 var value = parseFloat(text, 10); // Check if it's a fraction @@ -78,6 +79,10 @@ GTE.TREE = (function(parentModule) { // In order to get the previous text back, change text to current this.text this.changeText(this.text); } + } else { + //If it's empty, set its value to the last stored value + this.editable.setText(this.text); + } return this.value; };