Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading jquery UI in FF 11 give error:: "TypeError: a is undefined"

I am using jquery(ui as well) in my ff extension. All is working fine till ff 10.

var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);

loader.loadSubScript("chrome://myext/content/js/jquery-1.7.2.js",wnd);

var jQ = wnd.jQuery.noConflict(true);
  try {
          loader.loadSubScript("chrome://myext/content/js/jquery.ui.core.min.js", jQ);
  } catch (Except){
    alert(Except.toString());
  }

In FF 11 this code is not working. As per the above code, I am trying to load the jquery and then loading the jquery ui libs. Jquery is getting loaded but it doesn't load the "chrome://myext/content/js/jquery.ui.core.min.js" and give error "TypeError: a is undefined"

Any help would be appriciated.

like image 735
MKumar Avatar asked Mar 28 '12 11:03

MKumar


1 Answers

I had a similar error, but putting loadSubScript in this position it worked for me:

//load jQuery

var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
                       .getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://myext/content/lib/jquery-1.7.2.js",context);
var jQuery = window.jQuery.noConflict(true);

if( typeof(jQuery.fn._init) == 'undefined') { jQuery.fn._init = jQuery.fn.init; }

var $ = function(selector,context){ return new jQuery.fn.init(selector,context||myext.doc); };
$.fn = $.prototype = jQuery.fn;

myext.jQuery = jQuery;
myext.$ = $;

loader.loadSubScript("chrome://myext/content/lib/jquery.tablesorter.js",jQuery);
like image 157
liv913 Avatar answered Sep 21 '22 19:09

liv913