Javascript Novice flailing helplessly
I've been running into issues lately when trying to build custom cell templates that attempting to pass functions as parameters. I suspect this betrays my fundamental lack of understanding of javascript scopes and the this keyword. I have not had any luck on the net, as the stuff in this project is far more advanced than any JS tutorial i've seen on the net. I suppose I could risk my limited cash on a book, but in this day and age???
What I am trying to do here in the attached code is to create a template that contains a checkbox input, a hidden input, and a displayed label. and have the label default to the grid cells item text property from the corresponding model element.
fn(){return this.getItemProperty("text")}
I run into this problem all the time, I presumee b/c I just don't understand what is going on. My code fails from the line
If anyone can enlighten me (JS links, advice, recommended carreer changes;) I would really appreciate it. This same scenario seems to work sometimes, and not others, and I don't see the difference.
Thanks,
Here is the full code
What I am trying to do here in the attached code is to create a template that contains a checkbox input, a hidden input, and a displayed label. and have the label default to the grid cells item text property from the corresponding model element.
fn(){return this.getItemProperty("text")}
I run into this problem all the time, I presumee b/c I just don't understand what is going on. My code fails from the line
label.setContent("text", function() { return this.getItemProperty("text"); });
If anyone can enlighten me (JS links, advice, recommended carreer changes;) I would really appreciate it. This same scenario seems to work sometimes, and not others, and I don't see the difference.
Thanks,
Here is the full code
Active.Templates.Checkbox = Active.System.Template.subclass();
Active.Templates.Checkbox.create = function(){
/****************************************************************
Checkbox Cell template.
*****************************************************************/
var obj = this.prototype;
var _super = this.superclass.prototype;
obj.setTag("div");
obj.setClass("templates","input");
obj.defineTemplate("checkbox", new Active.HTML.INPUT);
obj.defineTemplate("hidden", new Active.HTML.INPUT);
obj.defineTemplate("label", new Active.HTML.SPAN);
var checkbox = obj.getCheckboxTemplate();
checkbox.setClass("input","checkbox");
checkbox.setClass("checkbox",function(){return this.getColumnProperty("index");});
checkbox.setAttribute("type","checkbox");
var hidden = obj.getHiddenTemplate();
hidden.setAttribute("type","hidden");
var label = obj.getLabelTemplate();
label.setClass("checkbox","label");
label.setContent("text", function() { return this.getItemProperty("text"); });
obj.setLabel = function( l ) {
var lbl = this.getLabelTemplate();
lbl.setContent( "text", l );
}
obj.setContent("checkbox", checkbox );
obj.setContent("hidden", function() { return this.getHiddenTemplate(); } );
obj.setContent("label", function() { return this.getLabelTemplate() });
};
Active.Templates.Checkbox.create();
gbegley
May 6,