Skip to Content
Former Member
Jan 09, 2013 at 04:40 PM

ListView Issue in Custom.js



I have been having a problem with viewing listviews. what i wanted to do was create a listview with the filter bar with a more attractive interface, which works fine upon first use. the user can open the home screen, click the button and see the results in the list with the filter bar and everything else i wanted. the issue is when i cancel out of the list or progress back to the home screen and click the button again to bring me to my listview screen everything seems to fall apart. ( If i click a list item it brings me to that items details as i wanted and when i go back from the details screen the listview remains perfect) the answer could be staring me in the face but i cant see it so all help would be appreciated.

After editing the custom.js file to change the standard listview to what I have shown below.

but when i cancel and return to the home screen and click the button to bring me to my listview screen again it appears as shown.

here is my code:

function customBeforeNavigateForward(screenKey, destScreenKey) {  if (!useJQuery) return true;        if (destScreenKey == 'Open_Requests'){//grab the results from our object query            var message = getCurrentMessageValueCollection();            var itemList = message.getData("Requests");            var items = itemList.getValue();            var numOfItems = items.length;            var i = 0;//iterate through the results and build our list            var htmlOutput = '<div><ul data-role="listview" data-theme="d" data-filter="true" >';            var firstChar = '';                        while ( i < numOfItems ){                var currItem= items[i];                var desc = currItem.getData("Requests_SHORT_TEXT_attribKey").getValue();                var matId = currItem.getData("Requests_PREQ_NO_attribKey").getValue();                var matNum = currItem.getData("Requests_PREQ_ITEM_attribKey").getValue();                                                var currFirstChar = desc.charAt(0);                if (currFirstChar != firstChar){                    firstChar = currFirstChar;                    htmlOutput += '<li data-role="list-divider" data-theme="a">'                    htmlOutput += firstChar;                    htmlOutput += '</li>'                }htmlOutput += '<li><a id ="' + currItem.getKey() + '" class="listClick">';                htmlOutput += '<h3>' + desc + '</h3>';                htmlOutput += '<p>' + matId + '</p>';                htmlOutput += '<p >' + matNum + '</p>';                htmlOutput += '</a></li>';                                i++;            }                        htmlOutput += '</ul></div>';                        if (destScreenKey == 'Open_Requests'){                $('#Open_RequestsForm').children().eq(2).hide();                $('#Open_RequestsForm').children().eq(1).after(htmlOutput);            }$(".listClick").click(function(){                currListDivID2 = $(this).parent().parent();                $(this).parent().parent().addClass("ui-btn-active");                                //special case for bb                navigateForward("Open_Requests_Detail", );                if (isBlackBerry()) {                     return;                }                        });                            }            return true;}

Again any and all help with this would be great.


Cian O Connor.