-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11-addons-index.html
53 lines (45 loc) · 1.82 KB
/
11-addons-index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{layout='layouts/_html-wrapper'}
{partial_search_functions}
<div class="container my-12 mx-auto px-4 md:px-12 w-10 inline-block align-top">
<div id="addon-results" class="flex flex-wrap -mx-1 lg:-mx-4">
</div>
</div>
<script>
//we're going to need the baseURL for several things here
function baseUrl() {
return location.protocol + '//' + location.hostname + (location.port ? ':' + location.port: '');
}
const resultsTarget = document.getElementById("addon-results");
const rp = baseUrl() + '/ajax/addon-results'
//on load create AJAX request
document.addEventListener('DOMContentLoaded', event =>{
//submit the response with fetch()
fetch(baseUrl() + "/ajax/addon-results")
// take our response and get the HTML we really want
.then(response => {
return response.text();
})
// take our HTML and replace the contents of our #addon-results element
.then(data => {
resultsTarget.innerHTML = data;
});
});
function ajaxFormSubmit () {
//get the form data
var searchForm = document.getElementById("addon_filter");
var formData = new FormData(searchForm);
//submit the data via AJAX
fetch(searchForm.action, {
method: 'post',
body: formData
})
// take our response and get the HTML we really want
.then(response => {
return response.text();
})
// take our HTML and replace the contents of our #addon-results element
.then(data =>{
resultsTarget.innerHTML = data;
})
}
</script>