Events for custom buttons in a custom component
Hi,
This is what i have right now:
I've added a panel to 2 pages.
The panel contains a custom component that i've created.
The custom component contains and HTML component with the following code:
precode
<ul data-role="listview" id="menuList" class="menuList ui-listview ui-group-theme-b" name="menuList" data-theme="b" data-divider-theme="b" data-count-theme="b">
<li class="ui-first-child" data-icon="false">
<a id="profileBtn" name="profileBtn" class="ui-btn" data-theme="b">
<i class="fa fa-user fa-lg"></i>
Profile</a>
</li>
<li class="ui-last-child" data-icon="false">
<a name="dishesBtn" class="ui-btn" data-theme="b">
<i class="fa fa-cutlery fa-lg"></i>
Dishes</a>
</li>
</ul>
/code/pre
What i want is to set the following click event on both pages on the same link
precode
$(document).off("click", '#profileBtn').on({
click: function() {
if (!$(this).attr('disabled')) {
Apperyio.navigateTo('Profile', {
reverse: false
});
}
},
}, '#profileBtn');
/code/pre
I've tried to put that code inside the HTML in a script tag but it only affects the first page, and on the second nothing is happening.
If i put similar code in the load event of each page (just using different selectors) it works.
Is it possible to do this so that the JS code would be only in one place instead of on each page?
Thanks!