/
index.html.ms.ejs
49 lines (40 loc) · 1.89 KB
/
index.html.ms.ejs
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
<div class="hero-unit">
<h3>Params</h3>
{{#params}}
<p>{{action}} action on {{controller}} controller.</p>
{{/params}}
</div>
<script type="text/javascript">
$(function () {
geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
var renderTemplate = function (<%= names.property.singular %>) {
var template = [ ''
, '<div class="row list-item" id="<%= names.property.singular %>-' + <%= names.property.singular %>.id + '">'
, ' <div class="span8">'
, ' <h3><a href="/<%= names.property.plural %>/' + <%= names.property.singular %>.id + '">' + <%= names.property.singular %>.<%= properties['default'].name || "id" %> + '</a></h3>'
, ' </div>'
, ' <div class="span4">'
, ' <h3><i class="icon-list-alt"></i>' + <%= names.property.singular %>.id + '</h3>'
, ' </div>'
, '</div>'
].join('');
return $(template);
}
var <%= names.constructor.plural %>Controller = function (opts) {
this.options = opts || {};
this.create = function (<%= names.property.singular %>) {
$('#<%= names.property.plural %>-list').append(renderTemplate(<%= names.property.singular %>));
};
this.update = function (<%= names.property.singular %>) {
$('#<%= names.property.singular %>-' + <%= names.property.singular %>.id).replaceWith(renderTemplate(<%= names.property.singular %>));
};
this.remove = function (id) {
$('#<%= names.property.singular %>-' + id).remove();
};
};
geddy.<%= names.constructor.plural %> = new <%= names.constructor.plural %>Controller();
geddy.model.<%= names.constructor.singular %>.on('save' , geddy.<%= names.constructor.plural %>.create);
geddy.model.<%= names.constructor.singular %>.on('update' , geddy.<%= names.constructor.plural %>.update);
geddy.model.<%= names.constructor.singular %>.on('remove' , geddy.<%= names.constructor.plural %>.remove);
});
</script>