Skip to content

Commit 208598b

Browse files
authored
Merge pull request #8 from dbezborodovrp/1.1-readme
Update 1.1 readme.
2 parents ae6ae95 + c7b4c6b commit 208598b

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

README.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
1-
# jquery.initialize
1+
# jQuery.initialize
22

3-
Version: 1.0.0, Last updated: 12/14/2016
3+
Version: 1.1.0, Last updated: 2017-02-06
44

5-
jquery.initialize plugin is created to help maintaining dynamically created elementes on page.
5+
jQuery.initialize plugin is created to help maintain dynamically created elements on the
6+
page.
67

7-
It has exacly the same syntax like jQuery $elem.each function.
8+
## Synopsis
89

9-
The difference is that jQuery elem .each function is called only once on elements that already exists on page right now.
10+
jQuery.initialize will iterate over each element that matches the selector and apply the
11+
callback function. It will then listen for any changes to the Document Object Model (DOM)
12+
and apply the callback function to any new elements inserted into to the document that
13+
match the original selector.
1014

11-
.initialize function will do what .each function does and then it will call function again on new items matching selector automatically just when they will be created by ajax or pretty much anything you can imagine to add new elements to page.
15+
$.initialize([selector], [callback])
1216

13-
Simple demo - [click here](http://adampietrasiak.github.io/jquery.initialize/test.html)
17+
This allows developers to define an initialization callback that is applied whenever a new
18+
element matching the selector is inserted into the DOM. It works for elements loaded via
19+
AJAX also.
1420

15-
---------------------------
21+
Simple demo - [click here](http://adampietrasiak.github.io/jQuery.initialize/test.html)
1622

17-
TODO: make it `bower` and `npm` compatible, add advanced performance test.
18-
19-
# Example of use
20-
21-
**Initialize has exactly the same syntax as with the .each function**
23+
## Example of use
2224

23-
$(".some-element").initialize( function(){
25+
$.initialize(".some-element", function() {
2426
$(this).css("color", "blue");
2527
});
2628

27-
But now if new element matching .some-element selector will appear on page, it will be instantly initialized. The way new item is added is not important, you dont need to care about any callbacks etc.
29+
But now if new element matching .some-element selector will appear on page, it will be instantly initialized. The way new item is added is not important, you dont need to care about any callbacks etc.
2830

29-
$("<div/>").addClass('some-element').appendTo("body"); //new element will have blue color!
30-
31+
$("<div/>").addClass("some-element").appendTo("body"); //new element will have blue color!
3132

32-
Note that plugin needs to know the selector of items you want to initialize. Thats why you need to **call initialize right after you've created jQuery element from selector.**
33-
34-
$(".some-element").initialize(myFunc); //will work
35-
$(".some-element").children().initialize(myFunc); //will NOT work
36-
37-
38-
39-
**Support**
33+
## Browser Compatibility
4034

4135
Plugin is based on **MutationObserver**. It will works on IE9+ (**read note below**) and every modern browser.
4236

@@ -45,7 +39,12 @@ Note: To make it work on IE9 and IE10 you'll need to add MutationObserver polyfi
4539
-----------------
4640
[Performance test](https://jsfiddle.net/x8vtfxtb/5/) (thanks to **@dbezborodovrp** and **@liuhongbo**)
4741

48-
# Contributors
42+
## Todo
43+
44+
- make it `bower` and `npm` compatible, add advanced performance test.
45+
46+
## Contributors
4947
- Adam Pietrasiak
5048
- Damien Bezborodov
51-
- Ninos Ego
49+
- Ninos Ego
50+
- Michael Hulse

0 commit comments

Comments
 (0)