EloquentStudio / filter.js

Complete solution for client side filtering and rendering using JSON data
http://eloquentstudio.github.io/filter.js
MIT License
665 stars 183 forks source link

Display JSon arguments #136

Closed Akia85 closed 7 years ago

Akia85 commented 7 years ago

JSON Object; { "id": 1, "Destination": "Mediterranean", "DestinationID": "192eefba-37e5-4f64-89dd-dcb4165c541d", "DepartureDate": "2014-03-21T03:27:49 -01:00", "Ship": "Explorer", "ShipID": "f2de6587-5e1a-4f80-aaad-939718356d19", "CruiseType": "Expedition", "Duration": 13, "AllInclusive": false, "WaitList": true, "FareFrom": 6741, "Currency": "$", "Cities": [ "culpa", "dolor", "nisi", "cillum", "ipsum", "tempor", "deserunt", "adipisicing", "excepteur", "enim", "id", "elit", "aute", "nulla", "laboris", "esse", "laborum" ], "VoyageCode": "{{integer(100, 9999)}", "Features": [ { "id": 0, "name": "Exclusive offer" }, { "id": 1, "name": "Venetian" }, { "id": 2, "name": "Diving" } ], "url": "test.com" },

When I put my tag like this :

<%= Features %>, I get in the view [object Object]. So I tried to access the arguments "Name' by this way:

  • <%= Features.name %> but it's not working.
  • <%= Features[0].name %> only display the first feature.

Is there a way to display all "Features" name in the

tag ?

Thank you for your help,

2016-09-07 13_07_27-testpage-filter html

jiren commented 7 years ago

You can use like this to get all Features

<%= Features.map(function(f) { return f.name }).join(', ') %>
Akia85 commented 7 years ago

Work perfectly ! Thank you for the fast answer !