Appending ID to dynamically created select option

Appending ID to dynamically created select option

codinglife456codinglife456 Posts: 4Questions: 2Answers: 0

What i am trying to do is to set an ID to the newly create select option however i am not sure how i am suppose to go about doing so. My current attempt results in an error saying that .attr function does not exist

option.label = "NA";
option.value = null;
option.attr('id','shift_na');
optionsSP.push(option);
editor.field('shift').update(optionsSP);

Answers

  • colincolin Posts: 11,300Questions: 0Answers: 1,931

    That's right, it's not a function, it's an option.

    Try something like:

    option = {
       value: null,
       label: 'N/A'.
       attr: {
          id: 'shift_na'
       }
    };
    

    Colin

Sign In or Register to comment.