Hi,
I've got a problem with the collapsible set. I'm trying to load data into it trough a JSON call but it only loads the first item correctly as header and information, and the second item he puts in the information of the first item.
- {
- "games": [
- {
- "id": "1",
- "game": "Burgermoordenaar",
- "locaties": [
- {
- "id": "1",
- "locatie": "De Keyserlei 22",
- "naam": "Quick",
- "status": "2",
- "items": [
- {
- "item": "Zakdoek",
- "info": "DNA van dhr. Jos (Hilton Hotel Groenplaats)"
- },
- {
- "item": "speeksel",
- "info": "test"
- }
- ]
- },
- {
- "id": "2",
- "locatie": "Groenplaats 32",
- "naam": "Hilton Groenplaats",
- "status": "1",
- "items": [
- {
- "item": "Getuige",
- "info": "De getuige heeft iemand herkend (mevr. Romina) - Karel De Grote Hoboken"
- }
- ]
- },
- {
- "id": "3",
- "locatie": "Salesianenlaan 30",
- "naam": "KDG Hoboken",
- "status": "0",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- },
- {
- "id": "2",
- "game": "game 2",
- "locaties": [
- {
- "locatie": "locatie 2.1",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 2.2",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 2.3",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- },
- {
- "id": "3",
- "game": "game 3",
- "locaties": [
- {
- "locatie": "locatie 3.1",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 3.2",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 3.3",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- }
- ]
- }
Here is my jQuery code:
function krijgInfo(){
$.getJSON("gegevens.txt", function(result){
$.each(result.games[currentGame - 1].locaties[currentLocation - 1].items, function(){
$(".infolijst").append("<div data-role='collapsible'>");
$(".infolijst").append("<h3>"+ this.item + "</h3><p>"+ this.info +"</p>");
$(".infolijst").append("</div>");
});
$(".infolijst, $.mobile.activePage").collapsible({refresh: true});
});
};