Today I wrote a simple utility function to get random numbers or random array items as part ot jQM{BR} project.
Quick Example:
App.utils.random(10);
// return random between 0 and 10
App.utils.random(5,10);
// return random between 5 and 10
App.utils.random(['red','blue','green','yellow']);
// return a random item from given array
How to include:
You can add “utils” library in you app.js source file:
define([
'jquery', 'jqmbr/AppClass',
'jqmbr/app.utils'
], function(
$, AppClass
) {
... app stuff ...
});
jqmbr/app.utils add utils namespace to the AppClass object.
NOTE: You can also usel AppClassFull in place of AppClass to load every available modules.
Source on GitHub:
You can see all App.utils methods on GitHub source!
Open GitHub!






