Pass data from JS to mustache template

Re: Pass data from JS to mustache template

by nest87 nest87 -
Number of replies: 0
I want to pass data which I fetched via webservice to my mustache template

That Repository function is written inside same js [repository.js] as below.

var getDataById= function(args) {
var request = {
methodname: 'block_myblock_webservice_name',
args: {
'id': args
}
};

var promise = Ajax.call([request])[0];
return promise;
};


view.js
--------
$(".card .dashboard-card[data-region=course-content]").closest('[data-course-id]').each(function() {

var id= $(this).data('course-id');

return Repository.getDataById(id)

.then(function(data) {

return Templates.render('block_my_blockname/templatename', data)

}).then(function(html, js) {

return Templates.replaceNodeContents('.teamplate_class_name', html, js);

}).catch(Notification.exception);

});