Download
User Rating: 4.3/5 ( 1 votes)
JQuery Repeat is a jquery plugin for filling out mock-ups. Repeat is for filling out mock-ups, making it easy to duplicate blocks of sample content.
The main use is duplicating sample content in templates, examples, prototypes and demo pages but without needing a server or maintaining a mess of copy-pasted HTML.
Other uses include mocking UI actions that add content, such as dummying pagination or faking infinite loading content.
It's simple but I do this so often when prototyping front-ends, I wrapped it in a single function.
Source: brm.io
1. INCLUDE JS FILES
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/libs/jquery.repeat.js"></script>
2. HTML
<ul>
<li>Sample 1</li>
<li>Sample 2</li>
</ul>
<ul>
<li>Sample 3</li>
<li>Sample 4</li>
</ul>
3. JAVASCRIPT
$('ul li')..repeat(n [, target, deepClone]);
Where:
n is the number of times to repeat the selection
target (optional) where to append the clones, otherwise appends to parents
deepClone (optional) whether to perform a deep clone, default is false
Every selected element is then cloned n times and inserted into to their respective parent(s) after the last element in the selection, or target if specified
Returns: the newly generated clones (in case you need to bind them or something)