In Sugarcrm (backbone.js) I am trying to get attribute from List (in .hbs file)
<div class='dropdown usersLegend'>
<ul class='dropdown-menu'></ul>
</div>
and bind data synamically like
_.each(data.users, function (user) {
list += '<li user_id="' + user.id + '"> ... </li>';
});
this.$('.usersLegend ul').html(list);
I made custom event in initialize
this.events = {
'click li': 'getselectedUser',
};
and in method i tried following code
let currentTarget = JSON.stringify(e.currentTarget);
if (currentTarget != null) {
var doc = new DOMParser().parseFromString(currentTarget, "text/xml");
var tmpDiv = doc.createElement('div');
tmpDiv.innerHTML = currentTarget;
var links = tmpDiv.getElementsByTagName('li');
[...links].forEach((link) => {
console.log(link.getAttribute('user_id'));
});
}
this way I am not getting user_id value , how can i bind user_id in custom event