Created
June 20, 2016 19:37
-
-
Save georgesunil81/0310675c8baffab603e083fe9cbd846f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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".