Comments (4)
I think concept of element index is not relevant here as it's calling this callback as soon as element has appeared on the screen, so it has no context of 'group' like map
or each
has.
Consider such case
Initially you have 5 .element
divs
Then you add 2 more .element
divs
Then you remove 3 of existing .element
divs
Then you add one more ----> what would you expect now to be i
inside this function?
from jquery.initialize.
I will expect the same result I get using $.each
or $.map
, to get the actual length of the elements that are exactly at that time in the DOM, in your example:
5 .element
divs (0,1,2,3,4)
add 2 = 7 .element
divs (0,1,2,3,4,5,6)
remove 3 = 4 .element
divs (0,1,2,3)
add 1 = .element
divs (0,1,2,3,4)
You can do this by setting a function with $.each
and run a function to "read" again the elements in the DOM, but that is exactly what I want to $.initialize
to do for me, I don't want to set up a function to update
the list of elements.
from jquery.initialize.
An iterator doesn't exactly make sense in this context since elements can be inserted into the DOM out of order, and also can appear in complex or nested trees, not just as siblings.
If you are insistent on this, you can off course do:
var i = 0;
$.initialize('.element', function(el) {
console.log(i);
i++;
});
Although I understand that it may make sense to have an iterator in some circumstances, nobody has asked for such a feature to date. I wonder for the sake of curiosity what your scenario is that you need this for?
from jquery.initialize.
Wontfix.
from jquery.initialize.
Related Issues (20)
- Greedy script? HOT 17
- Site for Docs and Demo HOT 3
- Increment version on push! HOT 4
- Fails in FF 58 HOT 3
- unsuscribe from the initialize? HOT 6
- .forEach() doesn't work in old versions of chrome HOT 7
- Using a jquery selector: $('selector') HOT 1
- Looking for maintainers HOT 8
- Support jQuery selectors HOT 17
- Remove initialize event HOT 3
- Not working HOT 2
- Include deprecated warning for old API HOT 3
- Initialize for multi clases is it possible ? HOT 7
- Dynamic loading execution order HOT 4
- Uncaught TypeError: Cannot read property 'querySelectorAll' of null HOT 2
- $.find.tokenize is missing in jQuery 3.7.0 HOT 5
- Refactor find/match algorithm
- Test Suite HOT 1
- No parentElement of html HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.initialize.