samedi 25 octobre 2014

problems with values in jquery with django


Vote count:

0




please help, how i can send variable from view to javascript? Like jquery i used simple example auto-filed field. Example (jquery):



<script type="text/javascript">
function findValue(li) {
if( li == null ) return alert("No match!");
if( !!li.extra ) var sValue = li.extra[0];
else var sValue = li.selectValue;
alert("The value you selected was: " + sValue);
}

function selectItem(li) {
findValue(li);
}

function formatItem(row) {
return row[0] + " (id: " + row[1] + ")";
}

function lookupAjax(){
var oSuggest = $("#CityAjax")[0].autocompleter;
oSuggest.findValue();

return false;
}

function lookupLocal(){
var oSuggest = $("#CityLocal")[0].autocompleter;

oSuggest.findValue();

return false;
}

$(document).ready(function() {
$("#CityAjax").autocomplete(
"autocomplete_ajax.cfm",
{
delay:10,

minChars:2,
matchSubset:1,
matchContains:1,
cacheLength:10,
onItemSelect:selectItem,
onFindValue:findValue,
formatItem:formatItem,
autoFill:true
}
);

$("#CityLocal").autocompleteArray(
["Albany", "Alexandria", "Alger", "Alledonia", "Alliance", "Alpha", "Alvada", "Alvordton", "Amanda", "Amelia", "Amesville", "Amherst", "Amlin", "Amsden",
],
{
delay:10,
minChars:1,
matchSubset:1,
onItemSelect:selectItem,
onFindValue:findValue,
autoFill:true,
maxItemsToShow:100
}
);
});
</script>


and there is exmaple value django (array) :



var = [u'zabbix[process,java poller,avg,busy]', u'vm.memory.size[total]', u'vmware.hv.hw.cpu.threads[{$URL},{HOST.HOST}]', u'agent.ping', u'zabbix[wcache,history,pfree]', u'agent.version', u'vmware.hv.network.in[{$URL},{HOST.HOST},bps]', u'vm.memory.size[available]', u'vmware.hv.hw.vendor[{$URL},{HOST.HOST}]', u'vmware.hv.hw.model[{$URL},{HOST.HOST}]', u'system.boottime', u'system.cpu.util[,user]', u'system.hostname', u'zabbix[queue,10m]' ]


Can someone explain me please, how i can do this?



asked 21 secs ago







problems with values in jquery with django

Aucun commentaire:

Enregistrer un commentaire