Display an object data from inside a variable using ractive

23 views
Skip to first unread message

aurelio.no...@gmail.com

unread,
Jan 12, 2017, 11:07:26 AM1/12/17
to Ractive.js
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
       
};



Chris Reeves

unread,
Jan 12, 2017, 1:03:29 PM1/12/17
to Ractive.js
You need to give Ractive the data either at init or using set. Try ractive.set('data', data) and then using {{data.isProfiled}} in the template.


Thanks, Chris

--
You received this message because you are subscribed to the Google Groups "Ractive.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ractive-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

aurelio.no...@gmail.com

unread,
Jan 14, 2017, 10:54:04 PM1/14/17
to Ractive.js
Made some updates, added some markup just to get the whole picture. I made the change on my javascript but I'm currently getting an error "Uncaught SyntaxError: Unexpected identifier"
 

    <div class="form-element-container">
       
<label>Company Name <span class="required">*</span></label>
       
<input type="text" class="form-text full-width" placeholder="Enter the company name" id="accountName" value="{{leadData.accountName}}"/>
   
</div>


   
<div class="col col2">
       
<label>Street Name.</label>
       
<input type="text" class="form-text" placeholder="-" id="streetName" value="{{leadData.streetName}}"/>
   
</div>


   
<div class="form-element-container default-cta-container">
       
<a class="button cta" on-click="addLead">Create Account</a>
   
</div>




    app
.on('addLead', function(event) {
       
var data         = app.get('leadData');
       
var proxy        = app.get('proxy');
       
var endpoint     = 'account/leads/';
       
var rt           = 'POST';
       
var url          = proxy+'?endpoint='+endpoint+'&rt='+rt;


        app
.set(data, data) ({
           
var leadData     = {
               
"accountName": data.accountName,
               
"streetName" : data.streetName,
           
};
       
});

   
});


Thanks, Chris

To unsubscribe from this group and stop receiving emails from it, send an email to ractive-js+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages