2

I have an ajax request which returns about 1300 json objects. Out of this objects i populate some ArrayProxies and views. Each ArrayProxy and therefore view contains about 15 objects and detailed informations about these objects.

Because of some logic here and there i takes about 5 seconds till all the data is loaded.

Now i need to know how i could make something like a loading bar or at least render each view seperatly.

My ajax loading code is simple:

$.getJSON('http://json.url, function(data) {
    $.each(data, function(i, obj) {
        var obj = App.ObjModel.create(obj);
        if (obj.get('isCalculable')) {
            App.ObjController.addObj(obj);
        }
    });
});

But how can i tell the Application to render the view after some conditions return true?

Thx for any help, Dima

2 Answers 2

4

Let Ember do the work to figure out when the data is loaded. Check in the view if the data is loaded, if it's not, display an animated gif or something. This will tell the user the data is not yet ready.

You can do this in your view with something like this:

{{#if controller.isLoaded}}
  Display controller.content in loop or something
{{else}}
  <img src="/spinner.gif"> Loading data...
{{/if}}

This code example is adapted from the offical Ember website. You can find it here at the very end.

Sign up to request clarification or add additional context in comments.

Comments

0

You could use a loading image inside a div or something and toggle its display during the starting and ending of the request.

Ajax request begins:

document.getElementById("LoadingImage").style.display="block";

After it completes:

document.getElementById("LoadingImage").style.display="none";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.