开发者

Adding a node with jQuery in a Firefox extension

I suspect that jQuery is not working ok in my extension... I'm using version 1.3.2, loaded with the following rows:

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

My problem is that, when running the following rows, the one tagged as 1 works, the 2 raises a misterious error "L is null" related to jQuery:

jQuery.noCo开发者_运维百科nflict();
$ = function(selector,context){ return new jQuery.fn.init(selector,myext.doc); };
$.fn = $.prototype = jQuery.fn;
$().ready(function() {
   $("menuitem#a").attr("label","Value set by jQuery!");             // 1
   $("menupopup#listacorsi").append("<menuitem label='newnode!'/>"); // 2

});

I supposed that second row should be good to add a child node to element #listacorsi. menuitem#a is a child of #listacorsi. Could you please help me to understand what's wrong with my coding?

Thanks and best regards,

Livio


You should be referencing $ variable like this:

$("body",window.content)

Also I have also used jQuery in my firefox extension it works seamlessly with no issues at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜