IE throws an exception on "self = this" in JavaScript?

Viewed 2056

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;

};
2 Answers
Related