Skip to content

Instantly share code, notes, and snippets.

@georgesunil81
Created June 20, 2016 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgesunil81/0310675c8baffab603e083fe9cbd846f to your computer and use it in GitHub Desktop.
Save georgesunil81/0310675c8baffab603e083fe9cbd846f to your computer and use it in GitHub Desktop.
//jobs model (Jobs.js)
define(['can/model/model'], function() {
var jobs = can.Model.extend({
getJobsList: function(params, success, error) {
return can.ajax({
type: 'GET',
url: '/job/All?' + params.queryString,
})
.then(success, error);
}
}, {
define: {
_Status: {
get: function() {
//alert("gets in get for status!");
switch(this.attr('status')) {
case 1: return 'Unassigned';
case 2: return 'Assigned';
}
}
}
}
});
return jobs;
});
//Jobs controller
define([
"jquery",
"can",
"app/models/Jobs" //Jobs model called here
], function($, can, jobs) {
return can.Control.extend({
init: function(el, options) {
var self = this;
var scope = this.scope = new (can.Map.extend({}))();
queryString = "&jobStatus=1&pageIndex=1&pageSize=10&sortBy=1&sortOrder=desc";
jobs.getJobsList({ queryString: queryString })
.done(function(response) {
if (response.isSuccessful) {
if (response.data.length !== 0) {
scope.attr('jobslist', response.data);
}
} else {
alert("No date returned!");
}
})
.fail(function(response) { //alert( "fail / error" ); //Technical errors!
alert("technical error");
});
el.html(can.view("app/pages/landingpage/LandingpageView", scope));
}
});
});
//LandingpageView.stache
{{#each jobslist}}
<p>{{jobid}}</p>
<p>{{jobname}}</p>
<p>{{_Status}}</p>
{{/each}}
@georgesunil81
Copy link
Author

jobid and jobname gets displayed correctly when the stache is rendered, but not _Status (getting a warning message "WARN: can/view/stache/mustache_core.js: Unable to find key or helper "_Status".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment