Issue in conditionally preventing the default action of anchor tag
<p>There is an anchor tag: inventoryHome which takes the user to a different page.</p>

<p>If the size of rateMap is greater than 0, I need to show a confirmation pop-up confirming if the user wants to discard the unsaved changes.</p>

<p>The method navigateToInv() is called if the user confirms the discard.</p>

<p>In the code below, though the navigateToInv() method is called &amp; the click event is getting triggered, the page is not navigating to the new page.</p>

<pre><code>&lt;li&gt;&lt;a href="&lt;%=request.getContextPath()%&gt;/inventory" id="inventoryHome"&gt; &lt;spring:message code="inventoryTab" /&gt;&lt;/a&gt;&lt;/li&gt;

    $('#inventoryHome').click(function(e) {
            if (Object.size(rateMap) &gt; 0) {

                e.preventDefault();
                showDiscardConfirmationPopUp(navigateToInv, false);
            }
        });

    var navigateToInv = function (){
        rateMap = new Object();
         $('#inventoryHome').trigger('click');
    }

 Object.size = function(obj) {
     var size = 0, key;
     for (key in obj) {
         if (obj.hasOwnProperty(key)) size++;
     }
     return size;
 };
</code></pre>

<p>Not able to identify the issue.</p>
