File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,42 @@ This code snippet will replace the HTML node `.mod_my_module` when clicking on `
5454
5555 </script >
5656```
57+ ### Ajax Calendar
58+ Add this to the ` cal_default.html5 ` template and add the CSS classes ` .calendar__next ` and ` .calendar__prev ` to the next and previous month links.
59+
60+ ``` html
61+ <script >
62+ $ (" .calendar__next, .calendar__prev" ).click (function (event ) {
63+ var element;
64+ // Get url of next Month
65+ var $url = window .location .origin + ' /' + $ (this ).attr (' href' );
66+ // Don't follow the link
67+ event .preventDefault ();
68+ // This is the elements div container like ".mod_my_module". "Allow ajax reload" has to be ticket for this element in the backend
69+ element = $ (this ).closest (' .mod_article' );
70+ // Add a css class to this element. An overlay and spinning icon can be set via css
71+ element .addClass (' ajax-reload-element-overlay' );
72+
73+ $ .ajax ({
74+ method: ' POST' ,
75+ url: $url,
76+ data: {
77+ // The data- attribute is set automatically
78+ ajax_reload_element: element .attr (' data-ajax-reload-element' )
79+ }
80+ })
81+ .done (function (response , status , xhr ) {
82+ if (' ok' === response .status ) {
83+ // Replace the DOM
84+ element .replaceWith (response .html );
85+ } else {
86+ // Reload the page as fallback
87+ location .reload ();
88+ }
89+ });
90+ });
91+ </script >
92+ ```
5793
5894### Ajax forms
5995
You can’t perform that action at this time.
0 commit comments