Select2 library working only once

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


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"

    var a = [12, 34, 66, 7];

    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%> ');
        data: a
1 Like

mark this as solution

How do we include the select2 library in frappe.

I used external cdn library for including multiselect libraries


//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.


//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.