Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Developer
Posts: 12
Registered: ‎11-01-2012
My Device: simulator
My Carrier: simulator

QML DataSet.load works perfectly on a button click, but fails in onCreationCompleted event

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...");
        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;
    Container {
        layout: StackLayout {
        Button {
            text: "Click me!"
            onClicked: {
                //  ddOptions.removeAll();
        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?