| 1 |
efrain |
1 |
//
|
|
|
2 |
// * Javascript
|
|
|
3 |
// *
|
|
|
4 |
// * @package ajaxdemo
|
|
|
5 |
// * Developer: 2020 Ricoshae Pty Ltd (http://ricoshae.com.au)
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
require(['core/first', 'jquery', 'jqueryui', 'core/ajax'], function(core, $, bootstrap, ajax) {
|
|
|
9 |
|
|
|
10 |
// -----------------------------
|
|
|
11 |
$(document).ready(function() {
|
|
|
12 |
|
|
|
13 |
// toggle event
|
|
|
14 |
$('#id_stickycolid').change(function() {
|
|
|
15 |
// get current value then call ajax to get new data
|
|
|
16 |
var selectedstickycolid = $('#id_stickycolid').val();
|
|
|
17 |
ajax.call([{
|
|
|
18 |
methodname: 'mod_stickynotes_get_notes_column_select',
|
|
|
19 |
args: {
|
|
|
20 |
'id': selectedstickycolid
|
|
|
21 |
},
|
|
|
22 |
}])[0].done(function(response) {
|
|
|
23 |
// clear out old values
|
|
|
24 |
$('#id_selectorder').html('');
|
|
|
25 |
var data = JSON.parse(response);
|
|
|
26 |
for (var i = 0; i < data.length; i++) {
|
|
|
27 |
$('<option/>').val(data[i].ordernote).html(data[i].message).appendTo('#id_selectorder');
|
|
|
28 |
}
|
|
|
29 |
setnewvalue();
|
|
|
30 |
return;
|
|
|
31 |
}).fail(function(err) {
|
|
|
32 |
console.log(err);
|
|
|
33 |
//notification.exception(new Error('Failed to load data'));
|
|
|
34 |
return;
|
|
|
35 |
});
|
|
|
36 |
|
|
|
37 |
});
|
|
|
38 |
|
|
|
39 |
$('#id_selectorder').change(function() {
|
|
|
40 |
setnewvalue();
|
|
|
41 |
});
|
|
|
42 |
|
|
|
43 |
function setnewvalue() {
|
|
|
44 |
console.log($('#id_selectorder').val());
|
|
|
45 |
$('input[name = ordernote]').val($('#id_selectorder ').val());
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
});
|
|
|
49 |
});
|