Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery.hoverIntent.js in Firefox extension does not load

According to this guide I tried to load JQuery to my Firefox extension.

var Myext = {

  loadJQuery: function(wnd) {
      var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
        .getService(Components.interfaces.mozIJSSubScriptLoader);
      loader.loadSubScript("chrome://myext/content/jquery-1.7.2.min.js", wnd);
      var jQuery = wnd.jQuery.noConflict(true);
      try {
        loader.loadSubScript("chrome://myext/content/jquery.hoverIntent.js", jQuery);
      catch (Except) {
        alert(Except.toString());
      }
      return jQuery;
  },

  onLoad: function(e) {
    Myext.jQuery = Myext.loadJQuery(window);
  },

  showDialog: function(e) {
    var $ = Myext.jQuery;
    /* JQuery code */
  }

}

window.addEventListener("load", function(e) { Myext.onLoad(e); }, false);
window.addEventListener("DOMContentLoaded", function(e) { Myext.showDialog(e); }, false);

Loader has a problem to load jquery.hoverIntent.js. I downloaded it here

error message: "Type Error: $ is undefined"

like image 505
xralf Avatar asked Nov 13 '22 08:11

xralf


1 Answers

In order to use .dialog() you need to include jQuery UI library also. Put the next line right after you loaded the jQuery library:

loader.loadSubScript("chrome://myext/content/jquery-ui-1.8.18.custom.min.js", wnd);

The last jQuery UI library you can download from here.

like image 177
gakhov Avatar answered Dec 18 '22 10:12

gakhov