Ability to initialise option items selected
See original GitHub issueI wanted to reflect settings in the DB when the page was loaded but could not find a way to add an option as selected. I have modified my local file thus:
'addOption' : function(options){
var that = this;
if (options.value !== undefined && options.value !== null){
options = [options];
}
$.each(options, function(index, option){
if (option.value !== undefined && option.value !== null &&
that.$element.find("option[value='"+option.value+"']").length === 0){
var $option = $('<option value="'+option.value+'">'+option.text+'</option>'),
index = parseInt((typeof option.index === 'undefined' ? that.$element.children().length : option.index)),
$container = option.nested === undefined ? that.$element : $("optgroup[label='"+option.nested+"']");
// PB: 23-06-2016: If marked as selected from start, reset template
if (option.selected != undefined)
$option = $('<option value="' + option.value + '" selected>' + option.text + '</option>')
$option.insertAt(index, $container);
that.generateLisFromOption($option.get(0), index, option.nested);
}
});
},
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Correct way to initialize with an option already selected? #143
I'm trying to initialize a ui-select input field with a previously saved option. What's the right way to go about selecting the option...
Read more >initialising option in <select></select> in angular 6
Show activity on this post. I want to run code (initialize)="selectedQueryType=queryTypes[0]" when the component mounts, so that default value ...
Read more >Solved: Combo Box Reset - Power Platform Community
I have an issue here: - I try Button. Pressed to Reset the selected items to "Fnd items" (that is before any item...
Read more >Select - Materialize
Select allows user input through specified options. Make sure you wrap it in a .input-field for proper alignment with other text fields.
Read more >Initialization Options - Items API - Learnosity Reference
Provide custom initialization options to the Annotations API. This can be used to enable or disable specific modules, or customize their behavior.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll search my code tomorrow to find how I call it.
My pleasure 😃