Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Ons-lazy-repeat, wait for promise within delegate



  • Hi there,

    i do have a bit of javascript understanding errors and am trying to figure out how to load content before some element is created, however, the content which needs to be loaded will be given by the object which is retrieved within the delegate. I have a onsen lazy repeat list and want to add the element AFTER some content was loaded for this element.

    The content is loaded within a promise.

    newsElement.delegate = {
                createItemContent: function (i) {  
                    var a = loadImage(i).then(function() {
                            return '<div><img src="thepathtotheimagegoeshere"/></div>'
                    })
                    ons.createElement(a);
                },
                countItems: function () {                
                    // Return the number of items here.
                    return len;
                }
    };
    

    I am always getting some “return needs to return a HTML Object”. Any help appreciated :-)

    Rgs,
    Ben