diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-05-04 03:02:01 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-05-04 03:02:01 +0300 |
| commit | 63f714d5a78b765c117ebf6bbdfdbd748dd45644 (patch) | |
| tree | 87a4db40e1ff699222ccfdf699a3904d1c665bfc /public/assets/js | |
| parent | 931a93cd7bae092e2752064568cebe407d2bf46e (diff) | |
| download | gyraf1gov-63f714d5a78b765c117ebf6bbdfdbd748dd45644.tar.gz gyraf1gov-63f714d5a78b765c117ebf6bbdfdbd748dd45644.tar.bz2 gyraf1gov-63f714d5a78b765c117ebf6bbdfdbd748dd45644.zip | |
authentication; invitation; activation; base form setup
Diffstat (limited to 'public/assets/js')
| -rw-r--r-- | public/assets/js/invitation.md | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/public/assets/js/invitation.md b/public/assets/js/invitation.md new file mode 100644 index 0000000..ebcf0f7 --- /dev/null +++ b/public/assets/js/invitation.md @@ -0,0 +1,51 @@ +# SELECT2 HANDLING + +handling select2 properties (case-study javascript code) + + +## get all options' loop through all ... + + opts = $('#sector').select2()[0].options + for(i=0; i<opts.length; i++) { el = opts[i]; console.log(el.value, el.text); } + + + +## set option by selected 'TEXT' + + var id; + for(i=0; i<opts.length; i++) { if (opts[i].text == 'TEXT') id = i; } + $('#sector').val(id).trigger('change); + + + +## prepare as functions + + function select2_set_text(control, t) { /* define function */ + opts = control.select2()[0].options; + var id; + for(i=0; i<opts.length; i++) { if (opts[i].text == t) id = i; } + control.val(id).trigger('change'); + } + select2_set_text( $('#sector') , '04 Physics') /* call */ + + + +## in multiple select2 ... + + function get_id_of_text( control , t) { /* define id from text */ + opts = control.select2()[0].options; + var id = false; + for(i=0; i<opts.length; i++) { + if (opts[i].text == t) id = i; + } + return id; + } + function select2_set_multi_text(control, t_list) { /* define function */ + var ids = []; + t_list.forEach (t => { let id = get_id_of_text(control, t); + if (id !== false) ids.push(id); + }) + control.val(ids).change(); + } + select2_set_multi_text( $('#tags') , ['crime', '90s']) /* call */ + |
