This is a migrated thread and some comments may be shown as answers.

Cannot add a photo to photoList array

1 Answer 19 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bill
Top achievements
Rank 1
bill asked on 02 Dec 2016, 06:19 PM

When the first application was built, it contained an array called photoList.  This array is the source for a listview object called photo-list.  the code will add an item to this object with the push command:

                   // simulator code, can remove when finished testing
                    var image = document.getElementById('lastImage');
                    if (photoModel.imageList.length >= 0) {
                        $("#file-info-div").hide();
                        $("#photo-list-div").show();
                    }
                    var widthMeasure = (photoModel.imageList.length + 1) * 100 + 5;
                    var scr = $("#photo-scroll-container");
                    scr.width(widthMeasure);
                    var serverImage = "images/server_room" + Math.floor(Math.random() * 3) + ".jpg";
                    photoModel.imageList.push({ fileName: serverImage });
                    photoModel.selectedPhoto = serverImage;
                    image.src = serverImage;

 

the html for this is :

    <div id="photo-list-div" hidden="hidden" style="height: 70px">
        <div id="photo-scroller" data-role="scroller" data-orientation="horizontal" style="height: 70px; z-index: 1000;">
            <div id="photo-scroll-container">
                <div id="photo-list" data-role="listview" data-template="template" data-bind="source: imageList, events: { click: imageSelect }" ></div>
            </div>
        </div>
    </div>

Now this same code is being used in another app, but when except that the push command never adds the photo to the list.

Please help.

Cliff

 

1 Answer, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 07 Dec 2016, 03:41 PM
Hello Cliff,

The provided code looks good to me. Confirm that the photoModel.imageList variable is initially defined as an empty array. If it is, in order to continue my investigation, could you please check for any JavaScript runtime errors that are logged in the developer console? You can follow the steps outlined in this article to open the developer tools in the simulator.

Additionally, it will help me a lot to isolate and eventually find a workaround for the problem if you provide a runnable sample application that clearly reproduces the issue. Alternately, you can share your real-life application. For this purpose, I'd recommend that you open a support ticket, which is private and comes with a guaranteed response time and share the application there. I will also ask for steps to reproduce the problem.

Let me know of your findings.

Regards,

Preslav
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
bill
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Share this question
or