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.
I’m also trying to figure how I can store the data on ractive variable and display on a different template or append it on JSON object and send it to the API
Store data into ractive variable and display on a different template
<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="form-element-container default-cta-container">
<a class="button cta" on-click="addLead">Create Account</a>
</div>
app.on('addLead', function() {
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,
};
console.log(data);
});
Store data into a ractive variable and pass it on json object and send it to the API
<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="form-element-container default-cta-container">
<a class="button cta" on-click="addLead">Create Account</a>
</div>
app.on('addLead', function() {
var proxy = app.get('proxy');
var endpoint = 'account/leads/';
var rt = 'POST';
var url = proxy+'?endpoint='+endpoint+'&rt='+rt;
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,
};
$.post(url, function(data) {
$.ajax({
type : 'POST',
url : url,
data : data,
success : alert('success')
});
});
console.log(data);
});