I have my html input element designated as a dropdownlist in code below. I have my list of items specified in 'data-source=' where my list of items is an array of string options, which is added to based on what the users picklist values are (dynamically filled picklist). However, I can't seem to get the default value to work. Specifying 'data-option-select' works, and sets the default, however, when I specify that the picklist is required, it doesn't recognize the 'data-option-select' as an actual selection and thinks I still need to select something. If the picklist is not required, it picks up the 'data-option-select' just fine as an option and saves that without me having to go select anything.
How can I specify this dropdownlist as required and set the default value? (I can't really do it in javascript as these picklists are dynamically created. I have no idea how many there are or necessarily what their names will be, so looking for a way to specify selected default in the html markup).
Also, I have tried 'data-select' but I get unexpected identifier (the value was a string with multiple words and white spaces). I tried setting data-select to an integer, but that got some 'charAt(0) is not a function' error. I even tried it with setting data-primitive-value="true" but that didn't do anything.
'<input id="'+fieldMap[i].fieldName+'Input" data-role="dropdownlist" data-bind="value:'+fieldMap[i].fieldName.toLowerCase()+'" data-option-label="'+fieldMap[i].defaultPicklist+'" data-option-select="'+fieldMap[i].defaultPicklist+'" required data-required-msg="Please Select Valid '+fieldMap[i].fieldLabel+'" data-source="[\'None\'';