I have the javascript dupe hammer on SO. I closed Uploading image file to php server as a duplicate earlier today, and I was just trying to edit the duplicate list to add a more appropriate question.

The Edit link works correctly, but when I click on the Add button the dialogue appears briefly then disappears, so I can never enter the new duplicate.


2 Answers 2


Problem can be seen in this file at line 77. This is the relevant part:

$addButton.on("click",function (e) {

        url: '/questions/originals/' + questionId + '/find-originals-popup',
        target: $('.container')
    .done(function ($popup) {
            callback: function() {

        $('#add-original-form').trigger("submit", function (ev) {
            /* more code here but it's omitted for brevity */

        // the short story here is that initialization doesn't complete until the "show" event is triggered.
        // but we can't trigger that NOW, because the popup isn't actually visible yet
        // popup gets faded in after this callback returns... 
        // so, spin the event loop and listen for animation completed after it has had time to start.
        // all this for the sake of re-using the duplicate dialog logic unchanged
        setTimeout(function () {
            $popup.promise().then(function () { $popup.find(".close-as-duplicate-pane").trigger("show"); });
        }, 0);


in particular look at the line $('#add-original-form').trigger("submit", function (ev) {. The code before it sets up the dialog for adding duplicate targets. And when it gets to said line it immediately submits. The jQuery .trigger() method will initiate the event (here "submit"). The function given after it will be passed in as extra parameters for the event handler (which is irrelevant in this case).

I suppose somebody meant to use .on() to set up an event handler for a submission.

$('#add-original-form').on("submit", function (ev) {
    /* more code here but it's omitted for brevity */

would have made sense as it sets the function as the handler and prevents the default behavior if this handler is triggered.

  • 4
    LOL, this looks like an answer I might have written if someone had submitted that code as a SO question.
    – Barmar
    Commented Jun 25 at 19:21

Thanks for spotting and reporting this bug. VLAZ's analysis is spot on and I made a silly mistake here when I upgraded a bunch of old jQuery code yesterday (i.e. changing a whole bunch of old-fashioned .submit() calls to either .on("submit", fn) or .trigger("submit")).

Unfortunately this mistake went completely unnoticed by our build pipeline and didn't show up in my manual testing.

Sorry for the inconvenience. A fix is on its way out to production and should arrive within the next ~15 minutes.

  • 4
    "Cleaning up" and "Upgrading" old code seems to be resposible for most bugs in Stack Exchange. Some of those bugs are not noticed quickly, or even after noticed and reported, it's missed by the devs and stay bugged for years. This makes me wonder: is it really worth it? I don't blame you, I blame the company, the management, for lack of proper development strategy. Commented Jun 26 at 12:45
  • 6
    @ShadowWizard I appreciate the thoughtful inquiry. Speaking as an engineer, I believe these particular upgrades are the right thing to do. It's not an either/or, "leave old code as is" or "clean up everything". There's more nuance. Yes, some things can totally stay old and crufty as long as they work fine. Others really need to be upgraded for the sake of our engineers' QOL or since it's the right thing to do for our users. This particular change was a sweeping upgrade in 500+ different places, and I messed up 2 of them. It happens, and with this upgrade we try to make it happen less often.
    – Ham Vocke StaffMod
    Commented Jun 26 at 13:33
  • 2
    Well I see the end results: bunch of bugs. Ideally, the company would hire QA people, or at least people whose role is to test things before they are published. Sadly, Stack Exchange chose to save money and not hire such people, and that is annoying. Commented Jun 26 at 17:28
  • 2
    I understand your frustration and I know that every bug that makes it to production is jarring for our users. We have QA folks and they do a terrific job to raise the bar. It's just as much my job to test things before they are being published and I failed doing it thoroughly enough this time. Our system is huge and showing its age, these things happen. Every time it happens we try to improve our deployment pipeline. And when (not if) these things happen, we try our very best to recover as fast as possible. Respectfully, I think blaming management in such a complex scenario is too simple.
    – Ham Vocke StaffMod
    Commented Jun 27 at 6:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .