If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

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

Web and WebWorks Development

Reply
Developer
nathanpc
Posts: 134
Registered: ‎05-19-2012
My Device: Torch 9800, PlayBook 64GB, Dev Alpha
My Carrier: VIVO Brazil

How to Correctly Append an Item to a Image List?

I'm trying to append a item to a bbUI Image List using the following code:

list = {
  createItem: function (fragment, image, title, desc, click) {
    var item = document.createElement("div");
    
    item.setAttribute("data-bb-type", "item");
    item.setAttribute("data-bb-title", title);
    item.setAttribute("data-bb-img", image);
    item.setAttribute("onclick", click);
    item.innerHTML = desc;
    
    fragment.appendChild(item);
  }
}

bb.init({
  ondomready: function (element, id) {
    if (id == "main") {
      var fragment = document.createDocumentFragment();

      list.createItem(fragment, "images/test.png", "Testing Title", "Here will go the description.", "alert('this was clicked')");
        
      document.getElementById("list-container").appendChild(fragment);
      $("#list-container").css("display", "block");
    }
  }
});

Maybe it's inserting the item after bbUI got stylized all the screen, but it doesn't get styled neither the HTML was edited by bbUI to turn it into a list item, added all those styling elements and changing the structure of the <div> (if compared with the one I tested by just putting it on the HTML source file).

 

Any ideas on how to do this correctly so it gets styled by bbUI?

If I helped you please click the "Like" button to support my work.
My apps: CherryNotes - Bookmarked - Requests
Social Me: about.me - Twitter
Please use plain text.
Developer
nathanpc
Posts: 134
Registered: ‎05-19-2012
My Device: Torch 9800, PlayBook 64GB, Dev Alpha
My Carrier: VIVO Brazil

Re: How to Correctly Append an Item to a Image List?

I managed to learn how to do it and wrote a tutorial about it so everyone can understand how to do this Using bbUI's onscreenready and ondomready to Dynamically Change Your HTML:smileyhappy:

If I helped you please click the "Like" button to support my work.
My apps: CherryNotes - Bookmarked - Requests
Social Me: about.me - Twitter
Please use plain text.