When a user empties the cart it removes all items and the page reloads. The page will reload in order to reset the buttons that are activated (all buttons with .button class will reset to there original state) There should be a way to reset the buttons without needing to reload the page. Instead of the function preforming location.reload is there a function that can reset all flags to "99cents.png"
<script>
$(".button").on('click', function(){
var flag = $(this).data('flag');
simpleCart.add({
name : $(this).attr("data-product-id"),
price : .99,
quantity : (flag ? -1 : 1)
});
$(this).attr("src", flag ? "99cents.png" : "m99cents.png");
$(this).data('flag', !flag);
});
function reloadFunction() {
location.reload();
}
</script>
Store the original state in a data also. When reloadFunction is called, you can retrieve the state from this property and replace the source attribute.
In the html:
In the javascript: