简体   繁体   中英

number box not firing event on keyup when value is 0

In my view I have an event like this:

events: {
      'click .po_total .updates_total': 'updateTotal',
      'focusout .po_total .updates_total': 'updateTotal',
      'keyup .po_total .updates_total': 'updateTotal'
}

The haml JSHTML is:

%input.span2#shipping.updates_total{type: "number", name: "shipping", min: "0.00", step: "0.01", value: "0.00"}

Here is the code for Update

updateTotal: function(e) {
  if(e){
    e.preventDefault();
    e.stopImmediatePropagation();
  }
  this.$el.find('.po_total #total').html(this.getOrderTotal());

  if (Application.Helpers.currencyToValue(this.$('#total').html()) > 0 ) {
    this.watchTotal(e);
  }
},

The problem is that the updateTotal event does not fire when the value is changed to 0. It works all other times, but not when it is 0. I need it to work when the value is 0 because there is conditional behavior that happens in updateTotal when the value is 0 that currently never happens.

How can I get an event to fire when the value changes to 0?an

It turns out that for some reason the events where not being initialized properly because of the .po_class. Although the dom structure was correct, this did not work for elements with 0 as the value. I removed that class, and now it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM