{{^searchresults}}Keine Treffer{{/searchresults}}
{{# js }}
require([
'jquery','core/ajax','core/templates', 'core/notification'
] , function($, ajax, templates, notification) {
function load_timetable(type, name, add) {
//alert(searchstring);
var promises = ajax.call([
{ methodname: 'mod_timetable_get', args: { type: type, name: name, week: 0 } },
]);
if (add=='1') {
promises[0].done(function(response) {
templates.render('mod_timetable/timetable',response).done(function(html, js) {
$('.timetables').append(html);
templates.runTemplateJS(js);
}).fail(notification.exception);
}).fail(function(ex) {
// do something with the exception
});
} else {
promises[0].done(function(response) {
templates.render('mod_timetable/timetable',response).done(function(html, js) {
if (!($('.timetables .timetable').length)) {
$('.timetables').prepend("");
}
$('.timetables .timetable').first().replaceWith(html);
templates.runTemplateJS(js);
}).fail(notification.exception);
}).fail(function(ex) {
// do something with the exception
});
}
}
$(".searchresults").click(function() {
console.log($(event.target));
element = $(event.target);
while (!(element.is('a'))) {
element = element.parent();
}
console.log(element);
load_timetable(element.data('type'),element.data('name'),element.data('add'));
});
});
{{/ js }}