What i want is to handle the anchor button click inside my Marionette.ItemView events. I don't want to use href in anchor tag. I want to handle the click in my itemview and ask the backbone approuter to change page.
I want to switch my page from index to myaccount on an anchor button click. My template looks like below
<div>
<a data-role="button" id="btn_eclipse" class="btn_eclipse_myaccount"><%= val_btn_myaccount %></a>
<a data-role="button" id="btn_eclipse" class="btn_eclipse_services"><%= val_btn_services %></a>
<a data-role="button" id="btn_eclipse" class="btn_eclipse_offers"><%= val_btn_offers %></a>
</div>
My Marionette.ItemView capture events like this
events : {
'click input[type="button"]' : 'onButtonClick',
'blur input[type="text"]' : 'onKeyPress',
'click a' : 'onAnchorButtonClick',
},
onAnchorButtonClick : function(obj){
obj.preventDefault;
var btn_id = $(obj.target).attr('id');
console.log("The button clicked id is==="+$(obj.target).attr('id'));
//here i trigger event to change page
}
I am not able to retrieve that ID or any other attribute like href as you specified in your answer from the anchor tag.
Please advice what should i do.
Thanks in advance.