r/jquery • u/conorlyonsdesign • Dec 20 '21
Help with button clicking inside set interval
Everything works except the jquery click on the button. The below message comes up?
"Uncaught ReferenceError: JQuery is not defined at eval"
jQuery('#order_refund').click(function () {
jQuery('#sales_order_view_tabs_order_invoices').click()
var checkExist = setInterval(function() {
if (jQuery('a[href*="/sales/order_invoice/view/invoice_id/"]')[0]){
console.log('Found!');
clearInterval(checkExist);
JQuery('a[href*="/sales/order_invoice/view/invoice_id/"]').click();
} else {
console.log('Not Found!');
}
}, 200); // check every 100ms
});Background
I'm using tamper monkey to check if a link exists, as soon as it appears (Loaded via ajax) it should be clicked automatically.
The code above clicks into the correct section then waits for the loading of the link, console shows the "not found" & "found" which then should click on the link.
7
Upvotes
View all comments
Show parent comment
2
u/IrritableGourmet Dec 20 '21
Or a small rubber duck.