Matt Snider![]()
This Y augmentation will add the Number namespace to the Y instance. This namespace will contain at least the following methods:
Format is probably the most powerful method, simplifying the conversion of numbers to string formats. Although I find myself using the isBetween/isNotBetween functions and the isEven/isOdd methods fairly regularly.
For a complete writeup, see the <a href="http://www.mattsnider.com/javascript/yui-3-number-gallery-component/">YUI 3 Number Gallery Component</a> article on my blog.
Here is an example showing several ways to format numbers using the Y.Number.format method.
<script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2010.03.10-18'
}).use('gallery-number', function(Y) {
Y.Number.format(1000); // will be "1,000.00"
Y.Number.format(1000, '0,0'); // will be "1,000"
Y.Number.format(1000000, "0") // will be "1000000"
Y.Number.format(1000000, "$0,0") // will be "$1,000,000"
});| Subject | Author | Date |
|---|---|---|
| Number module writeup on YUIBlog | Eric Miraglia | 03/11/10 |
© 2010 YUI Library - Site Credits