Expand my Community achievements bar.

Set coral ui 3 select dropdown value via jquery

Avatar

Level 5

I'm trying to set a coral UI dropdown box's value on a content fragment metadata screen via Jquery based on an AJAX call I make. The values are all setup already I just need to update the selected value from the default. However I run my jquery after document ready which sets the values successfully but something seems to come in and overrite these values as by the time I go to the relavent tab the values have reset.

 

 
3 Replies

Avatar

Administrator

Hi 

Please refer to this documentation :- https://docs.adobe.com/docs/en/aem/6-1/ref/coral-ui/docs/2.17.0-granite-004/select.html

//

Responding to User Interaction
The following shows how to respond to user interaction when an item is selected in the Select component above.
<script>
  $(document).ready(function () {
    var eventLog = $('#selectLog');
    $('#mySelect').on('selected', function(event) {
      eventLog.log('Value ' + event.selected + ' selected.');
    });
  });
</script>

 

Programmatically setting a selection
The following shows how to programmatically set the selected options in the Select component above
<script>
function selectBermuda() {
  var select = $('#mySelect').data('select');
  select.setValue('bm');
};
function selectAll() {
  var select = $('#mySelect').data('select');
  select.setValue(['bm', 'cm', 'dk', 'ec']);
};
function deselectAll() {
  var select = $('#mySelect').data('select');
  select.setValue();
};
</script>

 

I hope this would help you.

Thanks and regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 1

Hi,

Did you get a solution for the issue you were facing? I am also facing similar issue in the Fragment Editor.

Thanks.

Avatar

Level 5

FYI -- It looks like @kautuksahni's comment is for Coral UI 2, here's the instructions for Coral UI 3:

Setting the Selected Value in CoralUI 3