Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe you want to add an extra _each, and slightly change your existing one. Apologies if this code isn't 100%, as it might need tweaking to suit your data;</p> <pre><code> // Loop through your data, as each category _.each(this.collection.models, function(category){ // Loop through each image within the category _.each(category, function(image){ // Output your image var image_link='&lt;a class="fancybox" href="'+image.get('path')+'"&gt;'+ '&lt;img alt="" src="'+image.get('thumb_path')+'"&gt;'+ '&lt;/a&gt;'; $main.append(image_link); }); }); </code></pre> <p>To explain a bit better, you want to change from looping through just images;</p> <pre><code>[ { "id": "5", "gallery_cat_id": "2", "name": "rfg", "path": "/cms/app/webroot/files/images/img2.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/img2.jpg", "size": "149944", "sort_order": "10", "online": true, "created": "2013-08-16 10:24:37", "modified": "2013-08-17 08:37:05" }, { "id": "7", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p1060956.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p1060956.jpg", "size": "404269", "sort_order": "1", "online": true, "created": "2013-08-22 15:30:40", "modified": "2013-08-22 15:30:40" }, { "id": "8", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p1060959.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p1060959.jpg", "size": "258454", "sort_order": "2", "online": true, "created": "2013-08-22 15:30:57", "modified": "2013-08-22 15:30:57" } ] </code></pre> <p>...to looping through each category, and then each image inside that category;</p> <pre><code>[ { "Restorations": [ { "id": "7", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p1060956.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p1060956.jpg", "size": "404269", "sort_order": "1", "online": true, "created": "2013-08-22 15:30:40", "modified": "2013-08-22 15:30:40" }, { "id": "8", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p1060959.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p1060959.jpg", "size": "258454", "sort_order": "2", "online": true, "created": "2013-08-22 15:30:57", "modified": "2013-08-22 15:30:57" }, { "id": "9", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p1060964.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p1060964.jpg", "size": "309197", "sort_order": "3", "online": true, "created": "2013-08-22 15:31:10", "modified": "2013-08-22 15:31:10" }, { "id": "10", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p1060972.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p1060972.jpg", "size": "195725", "sort_order": "4", "online": true, "created": "2013-08-22 15:31:49", "modified": "2013-08-22 15:32:40" }, { "id": "11", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p1070598.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p1070598.jpg", "size": "229989", "sort_order": "5", "online": true, "created": "2013-08-22 15:32:02", "modified": "2013-08-22 15:32:02" }, { "id": "12", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/p10705991.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/p10705991.jpg", "size": "250559", "sort_order": "6", "online": true, "created": "2013-08-22 15:32:14", "modified": "2013-08-22 15:32:14" }, { "id": "13", "gallery_cat_id": "1", "name": "", "path": "/cms/app/webroot/files/images/pic_3.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/pic_3.jpg", "size": "191162", "sort_order": "7", "online": true, "created": "2013-08-22 15:32:27", "modified": "2013-08-22 15:32:27" } ], "Second Category - Sample": [ { "id": "5", "gallery_cat_id": "2", "name": "rfg", "path": "/cms/app/webroot/files/images/img2.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/img2.jpg", "size": "149944", "sort_order": "10", "online": true, "created": "2013-08-16 10:24:37", "modified": "2013-08-17 08:37:05" }, { "id": "14", "gallery_cat_id": "2", "name": "", "path": "/cms/app/webroot/files/images/tlbday3.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/tlbday3.jpg", "size": "25207", "sort_order": "2", "online": true, "created": "2013-08-23 14:20:04", "modified": "2013-08-23 14:20:04" }, { "id": "16", "gallery_cat_id": "2", "name": "", "path": "/cms/app/webroot/files/images/partyhats.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/partyhats.jpg", "size": "12955", "sort_order": "0", "online": true, "created": "2013-08-23 14:20:44", "modified": "2013-08-23 14:20:44" }, { "id": "18", "gallery_cat_id": "2", "name": "", "path": "/cms/app/webroot/files/images/hrc_syd_a5_happyhour_low.jpg", "thumb_path": "/cms/app/webroot/files/images/thumbs/hrc_syd_a5_happyhour_low.jpg", "size": "205515", "sort_order": "0", "online": true, "created": "2013-08-23 14:21:55", "modified": "2013-08-27 17:16:28" } ] } ] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload