I have this code that is working in all browsers, but for some reason Opera is being a big pain and throwing an error:
Uncaught exception: TypeError: 'OBJ.data' is not a function
I have my main plugin OBJECT called Box, within it I have a variable called content.
Box={
content:''
}
Upon clicking an image it assigns the image’s parent ‘a’ to the Box.content variable.
Box.content=$(this).parents('a:first');
I then reference this elsewhere in the plugin using:
Box.content.dosomething()....
This works in all browsers, except for Opera and IE which throws the above error. Any ideas?
Thanks!
;(function($){jQuery.fn.PluginName=function(options){var defaults={
....},
Box={content:''},
o=$.extend({},defaults,options||{});
function myFunction(){
// SHOULD BE ABLE TO REFENCE IT HERE....
Box.content.dosomething();
};
$('.image').bind('click',function(){
Box.content=$(this).parents('a:first');
// DO SOME OTHER STUFF
myFunction();
});
Found out that the problem has to do with IE and (haven’t check but am assuming) Opera as well are firing the Window resize event onload, which (at that the time Box.content variable is empty and unassigned). Here’s a related link:
enter link description here