Created
September 25, 2014 04:35
-
-
Save liviocunha/d2703b5ef05515f13f6b to your computer and use it in GitHub Desktop.
função js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$('select').on('change', inicio); | |
function inicio(){ | |
var id = $(this).val(); | |
var cat = {{pk}}; | |
dados = {'id':id, 'cat':cat}; | |
$.ajax({ | |
data : dados, | |
url : '/futebol/buscarajax/', | |
type: 'get', | |
success: function(data){ | |
console.log(data); | |
if (data.length >= '1' ){ | |
var html = '<li>Comentários<span>'+data.length+'</span></li><li></li>' | |
for (var i = 0; i < data.length; i++) { | |
html += '<li><a title="EDITAR" href="/futebol/comentarios/edit/'+data[i].pk+'/" rel="external"><h2>'+data[i].fields.name+'</h2><p>'+data[i].fields.desc+'</p></a></li><li ></li>' | |
} | |
$('#listcomentarios').html(html); | |
}else{ | |
var html = '' | |
html += '<li>Comentários</li><li><small>Sem comentários para o tipo.</small></li>' | |
$('#listcomentarios').html(html); | |
} | |
$('#listcomentarios').html(html); | |
$('#listcomentarios').listview('refresh'); | |
} | |
}); | |
} | |
</script> |
rustoceans
commented
Sep 25, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment