|
|
@@ -752,18 +752,33 @@ function frmTestSubmit(frm) {
|
|
|
//complete: true
|
|
|
});
|
|
|
},
|
|
|
- fetchOptionsForUser: function(input, callback) {
|
|
|
- var options = [];
|
|
|
- for (var i = 1; i <= 100; i++) {
|
|
|
- options.push({value: 'user' + i, label: 'User [' + i + ']'});
|
|
|
- }
|
|
|
- callback(null, {
|
|
|
- options: options,
|
|
|
- // CAREFUL! Only set this to true when there are no more options,
|
|
|
- // or more specific queries will not be sent to the server.
|
|
|
- //complete: true
|
|
|
- });
|
|
|
- }
|
|
|
+ fetchOptionsForUser: (function() {
|
|
|
+ var _userXhr = null;
|
|
|
+ return function(input, callback) {
|
|
|
+ if (_userXhr && _userXhr.state() === 'pending') {
|
|
|
+ _userXhr.abort();
|
|
|
+ _userXhr = null;
|
|
|
+ }
|
|
|
+ _userXhr = $.ajax({
|
|
|
+ url: 'index.php?_route=UserMsgs&_task=typeSpecialUserLogin&q=' + input,
|
|
|
+ dataType: 'json'
|
|
|
+ });
|
|
|
+ _userXhr.done(function(data, textStatus, jqXHR) {
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ var options = [];
|
|
|
+ data.forEach(function(item) {
|
|
|
+ options.push({value: item.id, label: item.name});
|
|
|
+ });
|
|
|
+ callback(null, {options: options});
|
|
|
+ } else {
|
|
|
+ callback("Error no data!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ _userXhr.always(function() {
|
|
|
+ _userXhr = null;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ })()
|
|
|
});
|
|
|
// jQuery("#widget-msg-tree").on('change', function(e, data) {
|
|
|
// console.log('#widget-msg-tree/MsgTree::onChange: data:', data);
|