Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am uploading an image with the JS SDK which is working fine.

When i need to display the image in a templated view I can use the following code which is working for me:

var img = user.get('profileimage').url();

But how about when i need to display the image from a collection?

So I display a list of users associated with another user account who have a profile image. But there does not seem to be a clear way to get this URL from the collection as I cannot call methods on the object from the template?

I tried templating out this attribute but it still does not give me the image:

user.attributes.profileImage._url

share|improve this question

1 Answer

Then dont call the object from template.

Rather, in your process, you should be able to iterate the collection and then call a template for each $User in the collection.

You will have a template that just handles one user/profile/pic at a time. Above that is an iterator on the collection.

To see sample code look for 'sample todo app' where you will see code like below:

   // Add a single todo item to the list by creating a view for it, and
    // appending its element to the `<ul>`.
    addOne: function(todo) {
      var view = new TodoView({model: todo});
      this.$("#todo-list").append(view.render().el);
    },

    // Add all items in the Todos collection at once.
    addAll: function(collection, filter) {
      this.$("#todo-list").html("");
      this.todos.each(this.addOne);
    },
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.