-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
72 lines (55 loc) · 1.6 KB
/
index.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
<meta charset="UTF-8">
<script type="text/javascript" src="./assets/js/night-proxy.js"></script>
<button type="button" onclick="addItem()">Adicionar ítem</button>
<div proxy-target="elemento_01">carregando...</div>
<div proxy-target="elemento_02">carregando...</div>
<script proxy-template="elemento_01" type="x-tmpl">
<hr>
<h1>{{ titulo_geral }}</h1>
<hr>
{{ #lista }}
<h4>{{ titulo }}</h4>
{{ /lista }}
</script>
<script proxy-template="elemento_02" type="x-tmpl">
<hr>
<h1>{{ titulo_geral }}</h1>
<hr>
{{ #lista }}
<h4>{{ titulo }}</h4>
{{ /lista }}
</script>
<script type="text/javascript">
proxy.initProxy();
// ALTERAMOS O OBJETO SETADO NO HTML
proxy.template.elemento_01.titulo_geral = "Titulo 01";
proxy.template.elemento_02.titulo_geral = "Titulo 02";
proxy.template.elemento_01.lista = []
proxy.template.elemento_02.lista = []
proxy.template.elemento_01.lista.add([
{ "titulo": "===> Item 1" },
{ "titulo": "===> Item 2" },
{ "titulo": "===> Item 3" },
{ "titulo": "===> Item 4" }
])
proxy.template.elemento_02.lista.add([
{ "titulo": "===> Item 1" },
{ "titulo": "===> Item 2" },
{ "titulo": "===> Item 3" },
{ "titulo": "===> Item 4" }
])
proxy.template.elemento_02.lista[1].delete();
function exemploAjax() {
$.ajax({
url: "https://api.example.com/data",
method: "GET",
dataType: "json",
success: function (response) {
proxy.template.elemento_01.lista = response.json
},
error: function (xhr, status, error) {
console.error("Erro na requisição:", error);
}
});
}
</script>