Revision c2c28bf922bd () - Diff

Link to this snippet: https://friendpaste.com/5116npq9e5mBbAeYPbDliG
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Filter either by first or lastname does not work like expected</title>
<script src="../lib/jquery-1.2.6.pack.js" type="text/javascript" charset="utf-8"></script>
<script src="../build/chain.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div style="margin-top:0.5em; border:1px solid #BBB;">
first:<input style="margin: 0.5em;" type="text" id="first-filter"/>
last: <input style="margin: 0.5em;" type="text" id="last-filter" />
</div>
<div style="color:#444;border:1px solid #BBB;" id="persons">
<div style="background:#DCE9F4;padding: 0.3em;margin:1px;" class="item">
<span class="first">First</span>
<span class="last">Last</span>
</div>
</div>
<script type="text/javascript" charset="utf-8">
$('#persons')
.items([
{first:'Isaac', last:'Newton'},
{first:'Johannes', last:'Keppler'},
{first:'Alessandro',last:'Volta'},
{first:'Blaise', last:'Pascal'},
{first:'Niels', last:'Bohr'},
{first:'Albert', last:'Einstein'},
{first:'Stephen', last:'Hawking'}
])
.chain();

$('#first-filter').keyup(function()
{
console.log($(this).val());
$('#persons').items('filter', $(this).val(), 'first');
});

$('#last-filter').keyup(function()
{
console.log($(this).val());
$('#persons').items('filter', $(this).val(), 'last');
});
</script>
</body>
</html>