I'm using kendo grid in my web page with module pattern as follows:
var foo = (function(){
function f1(){
//do something
}
function buildTemplate(sourcecolumn){
if(sourcecolumn) { //..return a span with formatting }
else //..return a span with source column as inner text
}
function buildGrid(){
//1. setup for grid
//.. add datasource to fetch records from db
//2. build columns
//..foreach over columns and send the template function
var columns = [];
for(i = 0; i<10; i++){
columns.push({
template: '#buildTemplate(colname)#',
width: 50
});
}
}
return {
init: function(){
//..bind click events
}
}
})();
$(document).ready(foo.init);
When I ran the page which will trigger the buildGrid() method, browser console shows buildTemplate is not defined.
Currently I've moved buildTemplate() outside of IIFE scope so that the function is already executed and the grid is able to display values. But, I don't want to expose the buildTemplate function to be public.
Is there a way I can still encapsulate the buildTemplate() method inside IIFE scope with prior execution ?
Aucun commentaire:
Enregistrer un commentaire