In SugarCRM (backbone.js) I am trying to get the custom attribute user_id from a list (in .hbs file)
<div class='dropdown usersLegend'>
<ul class='dropdown-menu'></ul>
</div>
and bind data dynamically 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 the 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 the user_id value. How can I bind the user_id in custom event?