Display an object data from inside a variable using ractive

I’m currently trying to learn ractive JS at the moment and I have stumbled upon this problem on how I can display the object from inside a variable. I tried samples like {{data.isProfiled}} or {{isProfiled}} but nothing seems to work.

   var data         = {
        "isProfiled": true,
        "isBaluarte": 0,
        "isVertical": 0,
        "isAffiliate": 0,
        "isBranch": 0,
        "id": 0,
        "dateRequested": "2017-01-12T07:13:19.717Z",
        "accountIdFk": 0,
        "accountLeadId": 1285689131,
        "accountName": "Noel String",
        "assignedEmployeeIdFk": 0,
        "unitNumber": "string",
        "floorNumber": "string",
        "buildingName": "string",
        "streetNumber": "string",
        "streetName": "string",
        "barangayIdFk": 0,
        "cityTownIdFk": 0,
        "provinceIdFk": 0,
        "regionIdFk": 0,
        "leadsIdentifier": "string",
        "salesRegion": "string",
        "egApproval": "string",
        "smsId": "string",
        "dateComSmsId": "2017-01-12T07:13:19.717Z",
        "egRemarks": "string",
        "dateComGbuTag": "2017-01-12T07:13:19.717Z",
        "sgRemarks": "string",
        "taggingDetailsIdFk": 0,
        "profiling": "string",
        "dateCompletedGbuTag": "2017-01-12T07:13:19.717Z",
        "gbuTagidFk": 0,
        "longitude": 0,
        "latitude": 0,
        "numberOfEmployees": "string",
        "tier": "string",
        "industryTypeIdFk": 0,
        "gbuMigration": "string",
        "finalReco": "string",
        "motherAccountId": 0,
        "remarksFindings": "string",
        "finalCompanyName": "string",
        "accountCategoryIdFk": 0,
        "sourceLeadIdFk": 0,
        "baluarte": true,
        "vertical": true,
        "affiliate": true,
        "branch": true,
        "profiled": true

Just pass that data object into the constructor function, like e.g.

const app = new Ractive({
  el: document.body,
  template: '{{isProfiled}}',

As the ractive instance references the same data object you passed in, you can change it later like

data.isProfiled = false

… or set it on the ractive instance directly like

app.set('isProfiled', true)

If this doesn’t answer your question, you’d have to show us some actual code besides the variable declaration though… ;-)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.