Empty data

24 views
Skip to first unread message

marceloudi

unread,
Apr 4, 2012, 9:41:16 PM4/4/12
to JavaScript Templates Engine PURE
Hi all!
I just receiving an empty reponse from code.

What I'm doing wrong???


<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="libs/jquery.js"></script>
<script src="libs/pure.js"></script>
</head>
<body>

<div id="container">
<div>
<fieldset id="fscustomer">
<legend id="lggcustomer"></legend>
<table id="tbemployee">
<tbody>
<tr id="tremployee">
<td id="tdempname">Employee Name</td>
<td id="tdeventcontainer">
<table id="tbevent">
<tr id="trevent">
<td id="tddate">Date:<input class="date" value="" name=""></td>
<td id="tdend">End:<input class="end" value="" name=""></td>
<td id="tdobs">Obs:<textarea class="obs" name=""></textarea></
td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</fieldset>
</div>
</div>



<script>
var ex06 = {

data:{
"Customers": [
{
"name":"Customer 1"
,"personid":"9999"
,"Employees": [
{
"name": "Marcelo"
,"Events": [
{"eventid": "1", "eventtype": "1", "date":
"01/12/2011","end":"15/12/2012","obs":"free text1"}
,{"eventid": "1", "eventtype": "1", "date":
"01/12/2011","end":"15/12/2012","obs":"free text2"}
]
}
,{
"name": "Mic"
,"Events": [
{"eventid": "1", "eventtype": "1", "date":
"01/12/2011","end":"15/12/2012","obs":"free text3"}
,{"eventid": "1", "eventtype": "1", "date":
"01/12/2011","end":"15/12/2012","obs":"free text4"}
]
}
]
}
]
},
directive:{
"#fscustomer" : {
'customer <- Customers':{
'#tbemployee #tremployee': {
'employee <- Employees': {
'#tbemployee #tremployee #tdempname' : 'employee.name',
'#tbemployee #tremployee #tdeventcontainer #trevent': {
//'#tbemployee #tremployee #tdeventcontainer #tbevent
#trevent': {
'event <- Events': {
'#tbemployee #tremployee #tdeventcontainer #trevent #tddate':
function(){return 'test1'},
'#tbemployee #tremployee #tdeventcontainer #trevent #tdend':
function(){return 'test1'},
'#tbemployee #tremployee #tdeventcontainer #trevent #tdobs':
function(){return 'test1'}
}
//}
}
}
}
}
}
}
};

$p('#container').render(ex06.data, ex06.directive);

</script>

</body>
</html>

marceloudi

unread,
Apr 4, 2012, 11:38:42 PM4/4/12
to JavaScript Templates Engine PURE
I'm just trying to repeat a higher level (above its first TR).
I followed https://github.com/pure/pure/blob/master/js/examples.js
this example, and rear a lot about,
but I dont find a way do it.

I have success in many others ways, but I'm not finding what's wrong.
Is PURE capable to do it?

Thanks

Marcelo
PS: you made a really brilliant job! Im studying to reach your
knowledge! 8D

Mic (BeeBole)

unread,
Apr 6, 2012, 6:27:53 PM4/6/12
to JavaScript Templates Engine PURE
Hello Marcelo,

Here's how I would do it instead:
https://gist.github.com/2323464

Some remarks:

** do not use id's inside your templates. An id must be unique, if you
repeat a TR, they will have all the same id.
The same apply if you re-use a template various times in the same
page.
** you did not add the properties for the loop in the directives eg:
customer.Employees, instead of Employees
** I've simplified both the HTML and the directive, there were too
many useless selectors and id's

On Apr 5, 5:38 am, marceloudi <marcelob...@gmail.com> wrote:
> I'm just trying to repeat a higher level (above its first TR).

> I followedhttps://github.com/pure/pure/blob/master/js/examples.js

Reply all
Reply to author
Forward
0 new messages