Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox extension with jquery 1.3+

I use jquery-1.2.6 within my Firefox extensions and it works great. Some days ago i wanted to update to the current version of jquery (1.31) but this does not seem to work anymore. Here is my technique to include jquery in my extensions:

$mb = jQuery.noConflict();
var doc = window.content.document
$mb("body", doc).slideToggle("slow");

I am aware of the technique described at this page, but that does not work either. So is there anybody here that uses a newer version than jquery-1.2.6 in Firefox extensions and can tell me how?

like image 325
bizzy Avatar asked Feb 10 '09 14:02

bizzy


2 Answers

i found a solution for my problem!

I will present it here so that others can use this as a reference. After a lot of searching and tearing my hair i found this bug report on the jquery bug tracker. You can download jquery 1.3.1 Revision: 6161 there which fixes the problem (the official 1.3.1 release is Revision: 6158).

Another great trick a found out is including library's like jquery "on the fly" in firefox extensions. Just include the following within some javascript file within your extension:

var jsLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
jsLoader.loadSubScript("chrome://{appname}/content/jquery-1.3.1_6161.js");
jQuery.noConflict();

//use jquery
var doc = window.content.document;
alert(jQuery("body", doc).html());

Update: Today version 1.3.2 was released and the problem seems to be solved!

like image 130
bizzy Avatar answered Nov 05 '22 20:11

bizzy


After window.content.document I don't see the semicolon, I think it's necessary.

like image 21
tanathos Avatar answered Nov 05 '22 21:11

tanathos