Custom Button working only once

Any way to make button work everytime it is clicked ??
like

frm.cscript.button=function(frm,cdt,cdn){
console.log(123);

it prints only one time but should be on every time it is clicked

i managed to perform action on every click but still i’m using frappe.require and it is only working for the first time on button click

why not use frappe.add_custom_button

i am using select2 library for multi select option . It is only working for the first time not after that untill i refresh the page. Need to make it work on every click of button.

any way to make select2 library work on every time button is clicked without refreshing the page ?

Can you check this, is it related to yours?

NVM, got the solution of my problem.

Thanks

Dear @nikzz you should share your solutions with others to get response from them in future.

2 Likes
// select2 library import here
frappe.ui.form.on("FASTRACK","button",function(frm){

var dialog = new frappe.ui.Dialog({
				
				fields: [
					{"fieldtype": "HTML", "fieldname":"data_button"},
					{'fieldname':'message','label': 'Message', 'fieldtype': 'Small Text',"reqd": 1,"placeholder":"Message"},
					{"fieldtype": "Button", "label":"Send", "fieldname": "update"}
					
			]
				});
console.log(rec)
var a=[12,34,66,7];
console.log(a);

$("#rec_id12").remove();
dialog.fields_dict.data_button.$wrapper.html('ID <select id=rec_id12 class="select2-container input-large form-control select2me" multiple=multiple style=width:100%> ');
$("#rec_id12").select2({
  data: a
});

dialog.show();
});

Problem with me was on second time, this field–> dialog.fields_dict.data_button.$wrapper.html('ID ') " was already there so there was problem when parsing through each line on second time it runs

1 Like