I have three simple buttons.
<div class="enter-btn">Enter</div>
<div class="all-btn">All</div>
<div class="category-all">
<div class="back-btn" data-action="">Back</div>
</div>
When you click on either Enter or All, it adds a data-action value to the Back button.
$(".enter-btn").bind("click", function() {
$(".back-btn").attr("data-action", "search-home");
});
$(".all-btn").bind("click", function() {
$(".back-btn").attr("data-action", "category-home");
});
$(".back-btn").bind("click", function() {
alert($(this).data("action"));
});
But if you click Enter first, then All the value on the Back buttons seems to hold the first value and not get the new one.
I've added a simple jsfiddle to show my issue.