12-30-2012 05:29 PM
I am experimenting with using Backbone Views to populate the contents of a BBU screen. So I have a blank BBUI screen which only contains the screen div and script tags to load the scripts with the code for the backbone views etc. The backbone views are responsible for creating the bbui divs and appending them to the bbui screen div. I created a controller to handle the onscreenready event and pass the element to a backbone view.
In my first experiment, I used a view which created a bbui imagelist from a backbone collection (and other sub backbone views) and appended the imagelist created at onscreenready to the blank bbui screen div.
It seemed to work but then I realised that the bbui title created by the backbone view covers the first element of the imagelist.
So if I had a list of 5, only four elements were visible. The five elements would be visible if I did not append the title bar. This problem only happens in BB10. BB6 and BB7 render as expected (tested with ripple and simulators).
I noticed that the element passed by onscreenready contains the bbui screen, and since I was appending to that element passed to the backbone view, I thought the error was appending to that and not the screen. So I tried passing element.firstChild (which is the bbui screen as far as I can tell) instead, but no change.
My other experiment was similar but I used backbone views to generate control groups and containers for input. Similar problem with the title bar, but I also can't select the input field to enter text. Again this only happens on BB10.
If I do not use backbone and manually enter the elements in the screen as normal it works as expected.
Any one have any ideas?
Solved! Go to Solution.
01-01-2013 09:02 PM
Found the problem.
When bbui processes a screen, there is a loop that adds the screen's nodes (excluding menu bars, title bars etc) to a div which functions as the scroll area. This scroll area is put in place below the title bar. The loop, however, does not add whatever the last node is. Since manually entered HTML has whitespace to make it easier for humans to read, the last node is typically a text node that represents whitespace. I did notice another exception, but won't get into it here.
My backbone views however, produces HTML without any whitespace, and since this end up being the last node in the screen, it is not being added to the scrollArea div. So I altered my backbone views to add an empty text node at the end to get the screens to work properly.
Hope they fix that loop at some point though.
01-08-2013 03:08 PM
I posted this issue on github and it has been fixed, so no need for the workaround any more.
https://github.com/blackberry/bbUI.js/issues/561