Ok - this I believe is really a javascript question - although I am using jQuery in the code...
So - I've got an IMAGE - a STAR - that when you click it it runs an event called addstarClick() - see code in the images below.
If you click the star when nothing on the screen is selected - it runs the event and you see in the top of the attached image that this, objWebParam, wesSave and wesThis all look properly setup - and the code works from that point forward.
The bottom image shows the star getting clicked when the focus is in a TEXTBOX in that SLICKGRID row. When addstarClick() fires you see that those same this, objWebParam, wesSave and wesThis variables all look "unselected" and thus undefined since they are not pointing to the correct star! If I click the "value" of this it goes to a single line of html that appears disconnected from anything. When you click the this in the first example FIREBUG brings you to the HTML you would expect that STAR to be within!!
At any rate - difference is that when you click the star with the textbox hot it runs the unwind code in this TextCellEditor - probably the isValueChanged, applyValue, serializeValue and the destroy...
I know this is one heck of a complicated post - but any assist on how to even debug it further would be greatly appreciated!!!
So - I've got an IMAGE - a STAR - that when you click it it runs an event called addstarClick() - see code in the images below.
If you click the star when nothing on the screen is selected - it runs the event and you see in the top of the attached image that this, objWebParam, wesSave and wesThis all look properly setup - and the code works from that point forward.
The bottom image shows the star getting clicked when the focus is in a TEXTBOX in that SLICKGRID row. When addstarClick() fires you see that those same this, objWebParam, wesSave and wesThis variables all look "unselected" and thus undefined since they are not pointing to the correct star! If I click the "value" of this it goes to a single line of html that appears disconnected from anything. When you click the this in the first example FIREBUG brings you to the HTML you would expect that STAR to be within!!
At any rate - difference is that when you click the star with the textbox hot it runs the unwind code in this TextCellEditor - probably the isValueChanged, applyValue, serializeValue and the destroy...
I know this is one heck of a complicated post - but any assist on how to even debug it further would be greatly appreciated!!!
Code:
TextCellEditor: function(args) {
var $input;
var defaultValue;
var scope = this;
this.init = function() {
$input = $("<INPUT type=text class='editor-text' />")
.appendTo(args.container)
.bind("keydown.nav", function(e) {
if (e.keyCode === $.ui.keyCode.LEFT || e.keyCode === $.ui.keyCode.RIGHT) {
e.stopImmediatePropagation();
}
})
.focus()
.select();
};
this.destroy = function() {
$input.remove();
};
this.focus = function() {
$input.focus();
};
this.getValue = function() {
return $input.val();
};
this.setValue = function(val) {
$input.val(val);
};
this.loadValue = function(item) {
defaultValue = item[args.column.field] || "";
$input.val(defaultValue);
$input[0].defaultValue = defaultValue;
$input.select();
};
this.serializeValue = function() {
return $input.val();
};
this.applyValue = function(item, state) {
item[args.column.field] = state;
};
this.isValueChanged = function() {
return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
};
this.validate = function() {
if (args.column.validator) {
var validationResults = args.column.validator($input.val());
if (!validationResults.valid)
return validationResults;
}
return {
valid: true,
msg: null
};
};
this.init();
},