I am using select2 library for multi-select but problem is it is working only once untill page is refreshed. If i click the close button of dialog box and then reopen the dialog then it doesn’t work untill page is refreshed.
Any suggestions
I am using select2 library for multi-select but problem is it is working only once untill page is refreshed. If i click the close button of dialog box and then reopen the dialog then it doesn’t work untill page is refreshed.
Any suggestions
Solved
Can you please post the solution here?
// select2 library import here
frappe.ui.form.on("mydoctype", "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();
});
mark this as solution
How do we include the select2 library in frappe.
I used external cdn library for including multiselect libraries
$.getScript("multiselect_cdn_url_here",function(){
//rest code
});
I ve tired to include the select2 library by uploading it in the erpnext/public/js n css folder copied the script. It’s not working neither giving any error.
Can u please share your code n guide me to have the multiple select option.
$.getScript("https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.8/css/select2.min.js",function(){
//rest code
});
Thats what I used in custom script. I don’t have the machine where I perofrmed those.
Hope the above code segment will help you
Thanks, but what about including of css.