jQuery(document).ready is not working

1,529 views
Skip to first unread message

Ebrahim

unread,
Jul 25, 2013, 10:29:33 AM7/25/13
to fir...@googlegroups.com
Hi all,

I have the following  simple code in my extension: 

--------------------------------------------------

Firebug.CommandLine.evaluate(commandString, Firebug.currentContext, null, null, function(res) {}, function failure() {});

jQuery(context.window.document).ready(function(){

    DO_SOMETHING();

});


--------------------------------------------------


the commandString is a JavaScript script that makes a change to the page; it may add new content to the page or change the existing content. I checked and it works.

Then the DO_SOMETHING function extracts the newly added content from the page. The problem is that DO_SOMETHING is not executed. The problem comes from the jQuery(context.window.document).ready... code. Is something wrong in the code? 

Thanks for any help,
Ebrahim




Jan Honza Odvarko

unread,
Jul 25, 2013, 11:53:23 AM7/25/13
to fir...@googlegroups.com

> The problem comes from the jQuery(context.window.document).ready... code. 
Is something wrong in the code?
Is your extension source available somewhere?

Note that you are trying to run jQuery within chrome scope, i.e. where Firefox extensions run.
So, it could be potential problem apart from the fact that jQuery must be properly included
in your extension scope.

Do you see any exceptions?
You could try to enclose the jQuery call in try-catch and see what exception could be there...

Honza

Ebrahim

unread,
Jul 26, 2013, 4:22:06 AM7/26/13
to fir...@googlegroups.com


On Thursday, July 25, 2013 5:53:23 PM UTC+2, Jan Honza Odvarko wrote:

> The problem comes from the jQuery(context.window.document).ready... code. 
Is something wrong in the code?
Is your extension source available somewhere?

Note that you are trying to run jQuery within chrome scope, i.e. where Firefox extensions run.
So, it could be potential problem apart from the fact that jQuery must be properly included
in your extension scope.

Could you please describe a bit more about this? I just execute a jQuery statement in my extension on the DOM currently loaded in FF. 
 

Do you see any exceptions?
You could try to enclose the jQuery call in try-catch and see what exception could be there...


I see no exception. Seems the JavaScript engine completely ignores the jQuery(context.window.document).ready(function().... code line. 
 
Ebrahim

Jan Honza Odvarko

unread,
Jul 26, 2013, 9:15:23 AM7/26/13
to fir...@googlegroups.com
On Friday, July 26, 2013 10:22:06 AM UTC+2, Ebrahim wrote:


On Thursday, July 25, 2013 5:53:23 PM UTC+2, Jan Honza Odvarko wrote:

> The problem comes from the jQuery(context.window.document).ready... code. 
Is something wrong in the code?
Is your extension source available somewhere?

Note that you are trying to run jQuery within chrome scope, i.e. where Firefox extensions run.
So, it could be potential problem apart from the fact that jQuery must be properly included
in your extension scope.

Could you please describe a bit more about this? I just execute a jQuery statement in my extension on the DOM currently loaded in FF. 
Since you are using Firebug's |context| object in the expression:
"jQuery(context.window.document).ready"

I suppose that the expression is executed within chrome scope.
But, chrome scope doesn't have default access to jQuery -
even if the current page (a content scope) has it included.

You need to explicitly include jQuery into your extension to
make it work (but note that I never done that so, not  sure)
if it works.

You might want to experiment with:

context.addEventListener(win, "load", onLoadHandler, true);

See e.g.
https://github.com/firebug/firebug/blob/master/extension/content/firebug/css/loadHandler.js#L54

 
 

Do you see any exceptions?
You could try to enclose the jQuery call in try-catch and see what exception could be there...


I see no exception. Seems the JavaScript engine completely ignores the jQuery(context.window.document).ready(function().... code line. 
This sounds weird.

Honza

 

Ebrahim

unread,
Jul 26, 2013, 12:44:27 PM7/26/13
to fir...@googlegroups.com
@Honza: I sent you my code. 

Thanks,
Ebrahim
Reply all
Reply to author
Forward
0 new messages