Search code examples
jqueryangularjskendo-uikendonumerictextbox

AngularJS: Kendo Clear all NumericText boxes of 0 when clicked/tapped


In AngularJS I have an unknown number of NumericTextBoxes (they are made in an ng-repeat):

<input kendo-numeric-text-box
   k-format="'c2'"
   class="form-control"
   k-min="0" k-max="10000000"
   k-ng-model="fund.Amount"/>

When a user clicks any text box, if the value is $0 then the field should clear. My users are complaining that they have to manually remove the 0 each time they tap a Kendo NumericTextBox.

I tried this but it fails:

$(function() {
  $('[data-role="numerictextbox"]').each(function(){
    var textbox = $(this);
    textbox.value(null);
  }); 
});

Solution

  • I found a simple work around for my purposes. Set the model that the Kendo Control is bound to equal to null. That way the Kendo control shows a blank, not $0