There is an anchor tag: inventoryHome which takes the user to a different page.
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.
The method navigateToInv() is called if the user confirms the discard.
In the code below, though the navigateToInv() method is called & the click event is getting triggered, the page is not navigating to the new page.
<li><a href="<%=request.getContextPath()%>/inventory" id="inventoryHome"> <spring:message code="inventoryTab" /></a></li>
$('#inventoryHome').click(function(e) {
if (Object.size(rateMap) > 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;
};
Not able to identify the issue.