Here’s what I have so far, a jquery hack. Works when adding tags but failing to remove them:
function update_tags(frm){
frappe.call({
method: "gia_events.api.update_tags",
args: {
lead: frm.doc.name
},
callback: function(r) {
console.log(r.message);
if (typeof r.message !== 'undefined' && r.message){
if (r.message === frm.doc.import_tags){ return; }
frm.set_value("import_tags", r.message);
frm.save();
frm.refresh_field('import_tags');
}
}
});
}
frappe.ui.form.on('Lead', {
refresh(frm) {
$('.tags-input').on('blur', function(){
update_tags(frm);
});
$('.remove-btn')
.on('blur', function(){
console.log('clicked');
update_tags(frm);
}) // incomplete
.css( "backgroundColor", "red" );
}
})