Skip to content
This repository was archived by the owner on Jan 16, 2020. It is now read-only.

Commit b8fbc3c

Browse files
committed
Added support for automatic unlinking through override of cleanData, and
through test of previously bound arrayChange handler. Hence improved perf and removed memory leak from demo pages. Some Chrome and FF specific bugs fixed.
1 parent 4b2ad5e commit b8fbc3c

File tree

6 files changed

+216
-221
lines changed

6 files changed

+216
-221
lines changed

beta2/1explicitOrDeclarative.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ <h3>Explicit</h3>
3636

3737
<div id="myExplicit">
3838
<p class="cityWrapper">
39-
City: <span data-jq-linkfrom="address.city" class="city"></span>
39+
City: <span class="city"></span>
40+
City: <span class="city"></span>
4041
</p>
4142
<p>
4243
<input name="city" />

beta2/2hierarchical.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
<button onclick="setName()">set name</button>
1212
<hr /><br />
1313

14-
<table id="myDeclarative">
14+
<table id="myDeclarative" data-jq-tmpl="contactListTmpl">
1515

1616
<tbody><tr><td>
1717

1818
<h3 data-jq-linkfrom="title"></h3>
1919
<input data-jq-linkto="title" data-jq-linkfrom="title" />
2020

2121
</td></tr></tbody>
22-
<tbody data-jq-path="people">
22+
<tbody data-jq-path="people" data-jq-tmpl="personTmpl">
2323

24-
<tr data-jq-path="0">
24+
<tr data-jq-path="">
2525
<td>
2626
Name: <span data-jq-linkfrom="firstName"></span> <span data-jq-linkfrom="lastName"></span>
2727
</td>
@@ -31,7 +31,7 @@ <h3 data-jq-linkfrom="title"></h3>
3131
</td>
3232
</tr>
3333

34-
<tr data-jq-path="1">
34+
<tr data-jq-path="">
3535
<td>
3636
Name: <span data-jq-linkfrom="firstName"></span> <span data-jq-linkfrom="lastName"></span>
3737
</td>
@@ -41,7 +41,7 @@ <h3 data-jq-linkfrom="title"></h3>
4141
</td>
4242
</tr>
4343

44-
<tr data-jq-path="2">
44+
<tr data-jq-path="">
4545
<td>
4646
Name: <span data-jq-linkfrom="firstName"></span> <span data-jq-linkfrom="lastName"></span>
4747
</td>

beta2/3collectionChange.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,37 @@
2222

2323
<table id="peopleGrid">
2424
<tbody>
25-
<tr class="row1" data-jq-path="0">
25+
<tr class="row1" data-jq-path="">
2626
<td>
2727
<button class="btnDelete">X</button>
2828
Name: <span data-jq-linkfrom="firstName"></span> <span data-jq-linkfrom="lastName"></span>
2929
</td>
3030
</tr>
31-
<tr class="row2" data-jq-path="0">
31+
<tr class="row2">
3232
<td>
3333
<input data-jq-linkto="firstName" data-jq-linkfrom="firstName" />
3434
<input data-jq-linkto="lastName" data-jq-linkfrom="lastName" />
3535
</td>
3636
</tr>
37-
<tr class="row1" data-jq-path="1">
37+
<tr class="row1" data-jq-path="">
3838
<td>
3939
<button class="btnDelete">X</button>
4040
Name: <span data-jq-linkfrom="firstName"></span> <span data-jq-linkfrom="lastName"></span>
4141
</td>
4242
</tr>
43-
<tr class="row2" data-jq-path="1">
43+
<tr class="row2">
4444
<td>
4545
<input data-jq-linkto="firstName" data-jq-linkfrom="firstName" />
4646
<input data-jq-linkto="lastName" data-jq-linkfrom="lastName" />
4747
</td>
4848
</tr>
49-
<tr class="row1" data-jq-path="2">
49+
<tr class="row1" data-jq-path="">
5050
<td>
5151
<button class="btnDelete">X</button>
5252
Name: <span data-jq-linkfrom="firstName"></span> <span data-jq-linkfrom="lastName"></span>
5353
</td>
5454
</tr>
55-
<tr class="row2" data-jq-path="2">
55+
<tr class="row2">
5656
<td>
5757
<input data-jq-linkto="firstName" data-jq-linkfrom="firstName" />
5858
<input data-jq-linkto="lastName" data-jq-linkfrom="lastName" />
@@ -92,14 +92,14 @@
9292
}
9393
];
9494

95-
$.dataLink( people, "#peopleGrid", { tmpl: "#personTmpl" }).pushValues();
95+
var savedlinks = $.dataLink( people, "#peopleGrid", "#personTmpl" ).pushValues();
9696

9797
$.dataLink( "#peopleGrid", people );
9898

9999
$( "#peopleGrid" )
100100
.delegate( ".btnDelete", "click", function() {
101-
102-
var index = $.viewItem( this ).index;
101+
var item = $.viewItem( this ),
102+
index = $.inArray( item.data, item.parent.data );
103103
$.changeArray( people, "splice", index, 1 );
104104

105105
});

beta2/4tmplRender.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,23 @@ <h3>Read-only</h3>
6666
}
6767
];
6868

69-
$.dataLink( people, "#peopleGrid", { tmpl: "#editTmpl" }).render().pushValues();
69+
$( "#peopleGrid" ).html(
70+
$( "#editTmpl" ).tmplRender( people, { annotate: true })
71+
);
72+
$.dataLink( people, "#peopleGrid", "#editTmpl" ).pushValues();
7073
$.dataLink( "#peopleGrid", people );
7174

72-
$.dataLink( people, "#peopleGrid2", { tmpl: "#readOnlyTmpl" }).render().pushValues();
75+
$( "#peopleGrid2" ).html(
76+
$( "#readOnlyTmpl" ).tmplRender( people, { annotate: true })
77+
);
78+
$.dataLink( people, "#peopleGrid2","#readOnlyTmpl" ).pushValues();
7379
$.dataLink( "#peopleGrid2", people );
7480

7581
$( "#peopleGrid" )
7682
.delegate( ".btnDelete", "click", function() {
77-
78-
var index = $.viewItem( this ).index;
83+
var item = $.viewItem( this ),
84+
index = $.inArray( item.data, item.parent.data );
7985
$.changeArray( people, "splice", index, 1 );
80-
8186
});
8287

8388
function setLastName() {

0 commit comments

Comments
 (0)