use directories for structure
This commit is contained in:
5
app/text/templates/sometext.ejs
Normal file
5
app/text/templates/sometext.ejs
Normal file
@@ -0,0 +1,5 @@
|
||||
<ul>
|
||||
<% for (var i=0; i<texts.length; i++) { %>
|
||||
<li data-id="<%= texts[i].id %>" class="js-link"><%= texts[i].description %></li>
|
||||
<% } %>
|
||||
</ul>
|
32
app/text/text.js
Normal file
32
app/text/text.js
Normal file
@@ -0,0 +1,32 @@
|
||||
(function() {
|
||||
// globals
|
||||
MyApp.Text = {};
|
||||
|
||||
// utility functions
|
||||
|
||||
// app functions
|
||||
MyApp.Text.renderTextPage = function() {
|
||||
$('.js-page-container').html(ejs.rr('/app/text/templates/sometext.ejs', {
|
||||
texts: [
|
||||
{
|
||||
id: 100,
|
||||
description: 'Some text with id 100'
|
||||
},
|
||||
{
|
||||
id: 200,
|
||||
description: 'Some other text with id 200. Click it!'
|
||||
}
|
||||
]
|
||||
}));
|
||||
};
|
||||
|
||||
// events
|
||||
$(document).on('click', '.js-link', function(ev) {
|
||||
var el = $(ev.currentTarget);
|
||||
var linkId = el.attr('data-id');
|
||||
PNotify.success('The text you clicked had id ' + linkId + '. Maybe next time I will do something with this id.');
|
||||
});
|
||||
|
||||
// app startup
|
||||
page('/text', MyApp.Text.renderTextPage);
|
||||
})();
|
Reference in New Issue
Block a user