The script runs in the console but fails in the firebug extension

22 views
Skip to first unread message

Ebrahim

unread,
Jul 10, 2013, 3:39:46 AM7/10/13
to fir...@googlegroups.com
The following code simulates the selection of options from a select element and firing the change event after. 

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

var selectElementA=jQuery('#ctl00_pageContentRegion_frameManufacturer');

var options = selectElementA.find('option').slice(1).toArray();

var delay=5000;

jQuery(document).ajaxComplete(function complete(e){

var option=options.shift();

if (option){

  option.selected=true;

  jQuery(function(){

setTimeout(function(){selectElementA.trigger('change');},delay);

  });

} else{

jQuery(document).unbind('ajaxComplete',complete);

}

}).trigger('ajaxComplete');


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

I run the script in the firebug console and it works (checked for http://www.wrenchscience.com/ ). 
Then I make some changes (as follows) and use the script in my firebug extension, but it is not working there. 
It only selects the first option from the select element without firing the change event and then stops working. Seems ajaxComplete is not firing for the second time. 

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

var selectElementA=jQuery('#ctl00_pageContentRegion_frameManufacturer',context.window.document);

var options = selectElementA.find('option').slice(1).toArray();

var delay=5000;

jQuery(context.window.document).ajaxComplete(function complete(e){

var option=options.shift();

if (option){

   option.selected=true;

   jQuery(function(){

 setTimeout(function(){selectElementA.trigger('change');},delay);

   });

} else{

jQuery(context.window.document).unbind('ajaxComplete',complete);

}

}).trigger('ajaxComplete');


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


I am using FF 22.0 and FB 1.12.0b2. 


What should I do to get it working? 

I would appreciate any help on this problem.

Ebrahim



Reply all
Reply to author
Forward
0 new messages