I have some objected oriented JS that works fine in firefox but not in IE 8 (though it will be IE 9 that we will need to support).
When I do:
"self = this;"
IE flags that as an error.
I am trying to set this to self to then use it in a jquery callback to call some other
method in my JS object.
this.upd_params = function () {
$("#add-parameter-modal").modal('hide');
var param_form = $('#add_param_form');
self = this;
this.added_params = [];
this.removed_params = [];
$('.unused_parameter').each(function (index, obj) {
if (obj.checked) {
id = self.get_idnum(obj.id);
self.add_param2list(id);
}
});
$('.used_parameter').each(function (index, obj) {
if (!obj.checked) {
id = self.get_idnum(obj.id);
self.remove_param(id);
}
});
this.upd_html();
cfg_form_changed = true;
};
I have some objected oriented JS that works fine in firefox but not in IE 8 (though it will be IE 9 that we will need to support).
When I do:
"self = this;"
IE flags that as an error.
I am trying to set this to self to then use it in a jquery callback to call some other
method in my JS object.
this.upd_params = function () {
$("#add-parameter-modal").modal('hide');
var param_form = $('#add_param_form');
self = this;
this.added_params = [];
this.removed_params = [];
$('.unused_parameter').each(function (index, obj) {
if (obj.checked) {
id = self.get_idnum(obj.id);
self.add_param2list(id);
}
});
$('.used_parameter').each(function (index, obj) {
if (!obj.checked) {
id = self.get_idnum(obj.id);
self.remove_param(id);
}
});
this.upd_html();
cfg_form_changed = true;
};
Share
Improve this question
edited Aug 17, 2012 at 23:48
user166390
asked Aug 17, 2012 at 21:37
user1456508user1456508
3,8312 gold badges16 silver badges12 bronze badges
1
- @JaredFarrish Oh, missed that entirely :) – user166390 Commented Aug 17, 2012 at 21:46
2 Answers
Reset to default 19Make sure self
is a locally-scoped (not global) variable.
var self = this;
Otherwise, self
refers to window.self
and assigning to it is not allowed.
Okay, i'm posting this because i believe its related and can be useful to others, if you do inline variable assigning, as the code below:
var var1 = value1,
var2 = value2,
self= this;
it will throw an Exception on IE saying Not Implemented.
You can fix it by changing to something like this:
var var1 = value1,
var2 = value2;
var self= this;