Iterator Pattern in jQuery
I'm starting to work in a plugin to allow custom iterator methods to a jQuery object.
The main idea is to be able to do something like this:
<span style="font-family: courier new,monospace;">(function($){</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> //do some stuff having my custom iterator as default iterator
//Can be a $(...).each() or $(...).rewind(), $(...).previous(), $(...).next(), etc<br style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;">})($.iterator({
'rewind': function(){...}, //Moves to the first element
'next': function(){...}, //Moves to the next element
'key': function(){...}, //Key of current element
'current': function(){...}, //Value of current element
'valid': fucntion(){...}, //Is the iterator valid (has a next element) ?
'previous': function(){...} //It Would be used to manipulate the iterator </span><span style="font-family: courier new,monospace;">manually</span>
<span style="font-family: courier new,monospace;">}));
<font face="arial,helvetica,sans-serif">Or</font>
$('div').iterator({options}).each(function(){
//do some stuff
})
<br style="font-family: courier new,monospace;"></span>
Is there already any other plugin in dealing with this? Any comments or sugestions?<br clear="all">
--
Reinaldo de Souza "JuniorZ"
<a href="http://reinaldojunior.net">http://reinaldojunior.net</a>
-- Non ducor, duco