]> git.agnieray.net Git - galette.git/blob - galette/templates/default/elements/js/choose_adh.js.twig
fa1cd2af9551ca3837b56572318ac3b7e17a32f2
[galette.git] / galette / templates / default / elements / js / choose_adh.js.twig
1 {% if js_chosen_id is not defined %}
2 {% set js_chosen_id = "#id_adh" %}
3 {% endif %}
4 var _adhselect = function() {
5 $('{{ js_chosen_id }}').dropdown({
6 match: 'text',
7 placeholder: '{{ _T("Search for name or ID and pick member") }}',
8 apiSettings: {
9 url: '{{ url_for("contributionMembers", {"page": 1, "search": "{query}"}) }}',
10 method: 'post',
11 onFailure: function(response, element, xhr) {
12 console.log(response);
13 },
14 onError: function(errorMessage, element, xhr) {
15 {% include "elements/js/modal.js.twig" with {
16 modal_title_twig: _T("An error occurred :(")|e("js"),
17 modal_content: "errorMessage",
18 modal_class: "tiny",
19 modal_content_class: "scrolling",
20 modal_deny_only: true,
21 modal_cancel_text: _T("Close")|e("js"),
22 modal_classname: "redalert",
23 } %}
24 }
25 }
26 });
27
28 $('#reset-contributor').on('click', function() {
29 $('{{ js_chosen_id }}').dropdown('restore defaults');
30 $('{{ js_chosen_id }}').dropdown('refresh');
31 });
32 }
33
34 $(function() {
35 _adhselect();
36 });