Set coral ui 3 select dropdown value via jquery | Community
Skip to main content
Level 4
August 3, 2016

Set coral ui 3 select dropdown value via jquery

  • August 3, 2016
  • 3 replies
  • 6824 views

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.

 

 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

kautuk_sahni
Community Manager
Community Manager
August 3, 2016

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
saurabhsarthwah
November 2, 2017

Hi,

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

Thanks.

dan_klco
Level 4
December 12, 2017

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