vendredi 6 février 2015

Cakephp: Accessing a database table from view

I have the following code inside a view, but I'm trying to use a table instead of the array 'tags' to access the data for the autocomplete function. Can I do that because I read somewhere that the view should not interact with the model? If I can, can someone guide me how to? Please I need help! Thank you.





<script id="source" language="javascript" type="text/javascript">
$(function() {

var tags = [
"THE PAS",
"THOMPSON",
"TREHERNE",
"VIRDEN",

];

$( "#tagOrig" ).autocomplete({
source: function (request, response) {
var matches = $.map(tags, function (tags) {
if ( tags.toUpperCase().indexOf(request.term.toUpperCase()) === 0 ) {
return tags;
}
});
response(matches);
}
});

</script>



Aucun commentaire:

Enregistrer un commentaire