mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 8636: apply auto-complete function to domain dropdown - create shared function applyAutoComplete().
This commit is contained in:
parent
ed465500a2
commit
198f8b3073
@ -133,12 +133,15 @@ function bindAddAccountButton() {
|
||||
initDialog("dialog_add_account", 450);
|
||||
|
||||
var $dialogAddAccount = $("#dialog_add_account");
|
||||
|
||||
var domainObjs = [];
|
||||
|
||||
//applyAutoComplete($field, commandString, jsonResponse1, jsonResponse2, objs);
|
||||
applyAutoComplete($dialogAddAccount.find("#domain"), "listDomains", "listdomainsresponse", "domain");
|
||||
|
||||
/*
|
||||
$dialogAddAccount.find("#domain").autocomplete({
|
||||
source: function(request, response) {
|
||||
$.ajax({
|
||||
data: createURL("command=listDomains&keyword=" + request.term),
|
||||
data: createURL("command=listDomains&keyword=" + request.term),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
domainObjs = json.listdomainsresponse.domain;
|
||||
@ -152,22 +155,8 @@ function bindAddAccountButton() {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
$.ajax({
|
||||
data: createURL("command=listDomains"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var domains = json.listdomainsresponse.domain;
|
||||
var $dropDownBox = $dialogAddAccount.find("#domain_dropdown").empty();
|
||||
if (domains != null && domains.length > 0) {
|
||||
for (var i = 0; i < domains.length; i++)
|
||||
$dropDownBox.append("<option value='" + fromdb(domains[i].id) + "'>" + fromdb(domains[i].name) + "</option>");
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
$("#add_account_button").unbind("click").bind("click", function(event) {
|
||||
$dialogAddAccount
|
||||
.dialog('option', 'buttons', {
|
||||
@ -187,10 +176,10 @@ function bindAddAccountButton() {
|
||||
var domainName = $thisDialog.find("#domain").val();
|
||||
var domainId;
|
||||
if(domainName != null && domainName.length > 0) {
|
||||
if(domainObjs != null && domainObjs.length > 0) {
|
||||
for(var i=0; i < domainObjs.length; i++) {
|
||||
if(fromdb(domainObjs[i].name) == domainName) {
|
||||
domainId = domainObjs[i].id;
|
||||
if(autoCompleteItems != null && autoCompleteItems.length > 0) {
|
||||
for(var i=0; i < autoCompleteItems.length; i++) {
|
||||
if(fromdb(autoCompleteItems[i].name) == domainName) {
|
||||
domainId = autoCompleteItems[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1051,6 +1051,28 @@ function getMidmenuId(jsonObj) {
|
||||
return "midmenuItem_" + jsonObj.id;
|
||||
}
|
||||
|
||||
var autoCompleteItems = [];
|
||||
function applyAutoComplete($field, commandString, jsonResponse1, jsonResponse2) {
|
||||
$field.autocomplete({
|
||||
source: function(request, response) {
|
||||
$.ajax({
|
||||
data: createURL("command="+commandString+"&keyword=" + request.term),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
autoCompleteItems = json[jsonResponse1][jsonResponse2];
|
||||
var array1 = [];
|
||||
if(autoCompleteItems != null && autoCompleteItems.length > 0) {
|
||||
for(var i=0; i < autoCompleteItems.length; i++)
|
||||
array1.push(fromdb(autoCompleteItems[i].name));
|
||||
}
|
||||
response(array1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//var lastSearchType;
|
||||
var currentCommandString;
|
||||
var searchParams;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user