storkCore

Check-in [db85a37148]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added a test that shows a problem in using clonedProperties and models
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:db85a371486d1064c400ef58aa1c37d261473c75
User & Date: setok 2018-02-06 10:35:03
Context
2018-02-06
12:28
(no comment) Leaf check-in: acabda570e user: setok tags: trunk
10:35
Create new branch named "clonedModelProps" check-in: fb079b9d93 user: setok tags: clonedModelProps
10:35
Added a test that shows a problem in using clonedProperties and models check-in: db85a37148 user: setok tags: trunk
2018-01-30
20:06
Updating some of the documentation check-in: 9c5b492093 user: setok tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added examples/clonedListModel.html.





























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title></title>
        <script type="text/javascript" src="../storkCore.js">
            </script>
        <script type="text/javascript" src="../list.js">
            </script>

</head>

<body>
<h1></h1>

<p>
The following lists should have different content. Two models are
created, one cloned from the other, with a list model within that is
used for the content. Normally that would lead to them having the same
content, but the list model ("items") is specified to be a
clonedProperty of the containing model, which means the two models do
not point to the same list model.
<h2>First List</h2>
<ul id="list1">  <!-- Container element -->
  <!-- Actual list items will be copied into here -->
</ul>


<h2>Second List</h2>
<ul id="list2">  <!-- Container element -->
  <!-- Actual list items will be copied into here -->
</ul>


<div style="display: none;">
  <ul>
    <!-- 'Template' for each item in the list -->
    <li id="item_#n"><span id="text_#n"></span></li>
  </ul>
</div>        


<hr>
<address></address>
<!-- hhmts start -->Last modified: Tue Feb  6 12:33:19 EET 2018 <!-- hhmts end -->
</body>
<script type="text/javascript">
var firstList = clone(ListController);
firstList.setListContainer(elementByID("list1"));

var listItem = clone(ListItemController);
listItem.setItemTemplate(elementByID("item_#n"));
listItem.linkTextProperty("text", "text");
firstList.setItemControllerPrototype(listItem);

var firstModel = clone(StorkModel);
firstModel.setProperty("items", clone(ListModel));
firstModel.clonedProperty("items", ListModel);

var secondModel = clone(firstModel);

firstItems = firstModel.getProperty("items");
firstItems.pushObject({text: "Foo"});
firstItems.pushObject({text: "Bar"});

var secondList = clone(ListController);
secondList.setListContainer(elementByID("list2"));
secondList.setItemControllerPrototype(listItem);

secondItems = secondModel.getProperty("items");
secondItems.pushObject({text: "Goo"});
secondItems.pushObject({text: "Gah"});

firstList.setModel(firstModel.getProperty("items"));
secondList.setModel(secondModel.getProperty("items"));

        </script>


        </html>