I have an app in backbone where I want to find inside a Json some records and print out.
my JSON is like this:
[
{
\"id\" : \"r1\",
\"hotel_id\
First you should split your rooms list by hotels and levels:
var rooms = _(allRooms.groupBy, "hotel_id");
for (var hotelid in rooms)
rooms[hotelid] = _.groupBy(rooms[hotelid], "level");
The "combinations" you're looking for is the cartesian product of the levels (for each hotel). You can use this helper function for example. Use it like this:
_.each(this.collection.models, function(hotel) {
var levels = rooms[hotel.id];
var combinations = cartesian(_.values(levels));
// put them on the hotel
});