34 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
		
			Executable file
		
	
	
	
	
| define([
 | |
|      'jquery','core/ajax','core/templates', 'core/notification'
 | |
| ], function($, ajax, templates, notification) {
 | |
| 
 | |
|     function search_timetable(searchstring) {
 | |
|         //alert(searchstring);
 | |
|         var promises = ajax.call([
 | |
|              { methodname: 'mod_timetable_search', args: { searchstring: searchstring } },
 | |
|             ]);
 | |
| 
 | |
|            promises[0].done(function(response) {
 | |
|                       console.log('mod_timetable/search is' + response);
 | |
|                templates.render('mod_timetable/searchresult',{searchresults: response}).done(function(html, js) {
 | |
|                           $('.searchresult').replaceWith(html);
 | |
|                           templates.runTemplateJS(js);
 | |
|                       }).fail(notification.exception);
 | |
|                   }).fail(function(ex) {
 | |
|                              // do something with the exception
 | |
|                   });
 | |
| 
 | |
|     }
 | |
| 
 | |
| 
 | |
|     return {
 | |
|         initialize: function () {
 | |
|             $(document).ready(function () {
 | |
|                 //alert('Hi there');
 | |
|                 $(".searchstring").keyup(function() {
 | |
|                     search_timetable($(this).val());
 | |
|                 });
 | |
|             });
 | |
|         }
 | |
|     };
 | |
| });
 | 
