How do you set the placeholder when using chosen js plugin

How do you set the placeholder when using chosen js plugin

ethics.systemsethics.systems Posts: 4Questions: 2Answers: 0
edited March 2016 in DataTables 1.10

The default placeholder doesn't seem to work when using chosen js plugin. I tried using data-placeholder but that breaks. When using just placeholder it just keeps coming up with the default selection, "select an option".

        
        fields: [               
                    {
                        "label": "Select A Vendor:",
                        "name": "vendor_select",
                        "type": "chosen",
                        "options": {
                            placeholder: "Select A Vendor"
                        }
                    }

                             ]

Answers

  • ethics.systemsethics.systems Posts: 4Questions: 2Answers: 0

    Just figured out how to set it on a somewhat global level, but still private to the datatables. Modify editor.chosen.js in the set function. I'm sure there is a way to do it from the javascript on the page, but so far this works for me.

        set: function ( conf, val ) {
            conf._input.attr('data-placeholder','Select A Vendor');
            conf._input.val( val ).trigger('chosen:updated');
        },
    
  • allanallan Posts: 61,824Questions: 1Answers: 10,131 Site admin

    The chosen documentation doesn't list placeholder as an option. Possibly you need to use placeholder_text_single which is does document.

    Allan

This discussion has been closed.