Why is this '$(...).trigger("click")' not working inside this function (jQuery)?
<p>The following function opens a popup window when I click a link:</p>

<pre><code>function popupPlace(dict) {
    $popup = $('div#dish-popup');
    $popup.render(dict,window.dishPopupTemplate);
    if(typeof(dict.dish) === 'undefined') {
        $popup.addClass('place-only');
    } else {
        $popup.removeClass('place-only');
    }

    var $place = $('div#dish-popup div.place');
    var place_id = dict.place._id;
    if(liked[place_id]) {
        $place.addClass('liked');
    } else {
        $place.removeClass('liked');
    }
    if(dict.place.likes) {
        $place.addClass('has-likes');
    } else {
        $place.addClass('zero-likes');
    }


    var tokens = window.currentSearchTermTokens;
    var tokenRegex = tokens &amp;&amp; new RegExp($.map(tokens, RegExp.escape).join('|'), 'gi');
    $.each(dict.place.products, function(n, product) {
        $product = $('#menu-item-'+product.id);
        if(liked[place_id+'/'+product.id]) {
            $product.addClass('liked');
        }
        if(tokens &amp;&amp; matchesDish(product, tokens)) {
            $product.addClass('matched');
            $product.highlight(tokenRegex);
        } else {
            $product.removeClass('matched');
            $product.removeHighlight();
        }
        if(product.likes) {
            $product.addClass('has-likes');
        } else {
            $product.addClass('zero-likes');
        }
    });

    $('#overlay').show();
    $('#dish-popup-container').show();

    // Scroll to matched dish
    $("a#scrolll").attr("href", "#" + $("li.matched").attr("id"));
    $("a#scrolll").trigger("click");

    // Hide dish results on mobile devices to prevent having a blank space at the bottom of the site
    if (Modernizr.mq('only screen and (max-width: 640px)')) {
        $('ol.results').hide();
    }

    $(".close-dish-popup").click(function() {
        $("#overlay").hide();
        $("#dish-popup-container").hide();
        $('ol.results').show();
        changeState({}, ['dish', 'place', 'serp']);
    });

    showPopupMap(dict.place, "dish-popup-map");
}
</code></pre>

<p>At the end you can see the following:</p>

<pre><code>    $("a#scrolll").trigger("click");
</code></pre>

<p>Everything works but that link is not being triggered as soon as the popup shows up:</p>

<pre><code>    $('#dish-popup-container').show();
</code></pre>

<p>Any suggestions to fix this?</p>
