37 lines
757 B
JavaScript
37 lines
757 B
JavaScript
(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');
|
|
new Noty({
|
|
type: 'success',
|
|
text: 'The text you clicked had id ' + linkId + '. Maybe next time I will do something with this id.',
|
|
timeout: 5000
|
|
}).show();
|
|
});
|
|
|
|
// app startup
|
|
page('/text', MyApp.Text.renderTextPage);
|
|
})();
|