JSFiddle - React, Tailwind, and code Playground
HTML
<div data-global-id="168" class="remove-as-favorite">remove as favorite</div>
JavaScript
var global_id = "";
$('.remove-as-favorite').on('click',function(){
global_id=$(this).data('global-id');
// this works
alert('here i am in something: ' + global_id);
// this doesn't work
event_handler.remove_as_favorite();
});
event_handler={
remove_as_favorite: function(){
alert("Before change global_id: == >" + global_id);
alert(" NOTE : global-id is ==> " + $(this).data('global-id'));
global_id=$(this).data('global-id');
alert("here i am global_id:" + global_id);
}
}