11-07-2012 02:03 AM
I am loading Json from a remote web service directly into controls on my Qml. In order to do this I am using the onCreationCompleted to load the data. On the first page of my application this event works perfectly, on a second page it also works, but only in a button click event. It fails wehn I call it from onCreationCompleted. My application hangs and there is no console output or clues as to why it is breaking.
import bb.cascades 1.0
import bb.data 1.0
Page {
onCreationCompleted: {
console.log("going to load data...");
ds.load();
console.log("Loaded data..."); // This prints, but afterward the application hangs and the debugger eventually crashes!
}
function addOptionToDropdown(inputText, inputValue) {
var newOption = newOptionDef.createObject();
newOption.text = inputText;
newOption.value = inputValue;
ddOptions.add(newOption);
}
Container {
layout: StackLayout {
}
Button {
text: "Click me!"
onClicked: {
// ddOptions.removeAll();
ds.load();
}
}
DropDown {
id: ddOptions
title: "Reminder"
enabled: true
onSelectedIndexChanged: {
console.log("SelectedIndex was changed to " + selectedIndex);
}
}
attachedObjects: [
ComponentDefinition {
id: newOptionDef
Option {
}
},
DataSource {
id: ds
source: "http://address/of/service"
type: DataSourceType.Json
onDataLoaded: {
for (var i = 0; i < data.length; i ++) {
// set an object similar to foreach
var item = data[i];
addOptionToDropdown(d.prop1, d.prop2);
}
}
}
]
}
}
What can be casuing this and how can I debug it?