jquery global plugin parsing inputs
I am trying to do this with jquery globalization plugin but it fails in the browser (client script error, indexOf()
)
var newquantity = $.global.parseFloat(edititem.find('td.edititem-quantity > input'));
I used to use the jquery calculation plugin like this:
var newdiscount = edititem.find('td.edititem-discount > input').parseNumber();
and it worked but I'm changing to jquery globalization because of some i18n options it has and would like to use just one of those two plugins rather than both of them on the same site.
Why is the first one开发者_运维问答 failing?
I'm guessing that you might want:
var newquantity = $.global.parseFloat(edititem.find('td.edititem-quantity > input').val());
to get the <input>
element's value.
edit — updated: perhaps the value is null sometimes:
var newquantity =
$.global.parseFloat(edititem.find('td.edititem-quantity > input').val() || '');
Looking at the source code to the globalization "parseFloat()" function, the first thing it does with the first argument (which, indeed, must be a string, not a jQuery object) is call ".indexOf()". If the value passed in is null, then you'll get an immediate error.
精彩评论