I am creating a jquery plugin. this works fine in chrome, Mozilla, and IE 9, but in IE 8/7 I get a Permission denied error in the line "$ ctxObj.control2.val (opt.topicDefaultText);"

Test.Plugin = function () { var $ctxObj = {}; var opt = {}; var initEvents = function() { $ctxObj.control2.val(opt.topicDefaultText); $ctxObj.control2.on('click', function (e) { somefunction(); }); $ctxObj.control1.on('click',function(){ anotherfunction(); }); }; return { init: function (options) { var defaultOptions = { control1: '#control1', control2: '#control2', topicDefaultText:'test' }; opt = $.extend({}, defaultOptions, options); $ctxObj.control1 = $(opt.control1); $ctxObj.control2 = $(opt.control2); initEvents(); } };
} ();
if I declare a variable for each control, as shown below:
var $ control1 = $ ('# control1');
var $ control2 = $ ('# control2');
and then using the code
$control2.val(opt.topicDefaultText); $control2.on('click', function (e) { somefunction(); }); $control1.on('click',function(){ anotherfunction(); });
using the above code. I do not get any errors in IE, but, like in this plugin, I have so many controls, so I do not want to do this.
source share