Editor - Default Selects in New Form to Nothing Selected?

Editor - Default Selects in New Form to Nothing Selected?

andyrandyr Posts: 35Questions: 6Answers: 0

I want all the selects in the New form to start with nothing selected, instead of the first item. This works, but feels like a kludge.

editor.on("open", function (e, type) {
     if (editor.s.action == "create") 
             $("select").prop("selectedIndex", -1);
});

Is there a way to do this below with an property:

 var editor = new $.fn.dataTable.Editor({
  ...
        {
             "label" : "the label",
             "name" : "the field name",
              "type": "select"
              // Can I set a property here?
             },

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,903Questions: 1Answers: 10,148 Site admin
    Answer ✓

    The browser will automatically show select lists with the first item selected, so what you would need to do is add an empty option at the top of the list and the browser would select that.

    The alternative is to use an event as you suggest.

    Regards,
    Allan

This discussion has been closed.