Closed GoogleCodeExporter closed 8 years ago
This seems to be a problem that you want to parse a field into a percentage
formatable number but not include the percentage sign sometimes (e.g. 1.15 ->
0.0115). I suggest if you do not need real percentage support simply add/remove
the % sign your side and do not use % in the format options, might make things
easier for you.
I've fixed this issue by added the 'isPercentage' option to the parse method,
so if it's set to true then it's always taken as a percentage, regardless of if
it ends with % or not. I think this solves your problem officially rather than
a work around.
I realise now that the percentage support was not fully joined-up on the
parsing and formatting method, so real-world usage was always going to be a
problem. Hopefully this is now much easier to work with.
Examples -
1.15
$('div').parseNumber({locale:"us", isPercentage: true});
$('div').formatNumber({format:"#.##%", locale:"us"});
=1.15%
3.21%
$('div').parseNumber({locale:"us", isPercentage: true});
$('div').formatNumber({format:"#.##%", locale:"us"});
=3.21%
Fixed as of r18 and will be released with 1.2.3.
Original comment by apar...@gmail.com
on 5 Feb 2012 at 2:08
This issue was closed by revision r18.
Original comment by apar...@gmail.com
on 5 Feb 2012 at 2:08
Original issue reported on code.google.com by
darwinca...@gmail.com
on 29 Aug 2011 at 5:37