1

I started off thinking I could make a little bookmarklet to check the "Notify customer by email" box and then submit a shipment. It should have taken seconds. I've been banging my head against a brick wall for hours! Now it's personal.

Here's what I know:

Checking the "notify customer checkbox is easy enough: $("#send_email").prop('checked',1);

The button tag has this attribute onclick="submitShipment(this)" so I should either be able to trigger the button's click event or call the function directly, passing the button element as the argument. The button can be selected like so: $("button[title='Submit Shipment']")

I've tried all of the following:

  • $("button[title='Submit Shipment']").click();
  • $("button[title='Submit Shipment']").trigger("click");
  • $("button[title='Submit Shipment']")[0].click();
  • $("button[title='Submit Shipment']").onclick();
  • Event.fire($("button[title='Submit Shipment']"),'click');
  • this:

    var evt = document.createEvent("HTMLEvents");
    evt.initEvent('click', true, true ); 
    $("button[title='Submit Shipment']").dispatchEvent(evt);
    
  • and even this:

    $.ajax({
      url:'https://raw.githubusercontent.com/eduardolundgren/jquery-simulate/master/jquery.simulate.js',
        dataType: "script",
        success: function(data, textStatus, jqxhr){
        eval(data);
        $("button[title='Submit Shipment']").simulate("click");
       }
    });
    

I'm all out of ideas! Can anyone help out?

2

I finally figured it out. I should have been using Prototype, not jQuery. Here's the working code:

$$("#send_email")[0].checked = true;$$("button[title='Submit Shipment']")[0].click();

I intend to use this as a bookmarklet to speed up the shipping process a bit - Instead of the mind-numbingly boring task of scrolling down the page, clicking the checkbox then clicking the ship button for every order that's been processed, I can crtl+tab through all the orders, shipping them in record time.

(I will probably have to process orders at this blinding pace for several hundreds of years to make up for the lost time spent figuring out this solution)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.