Is there a way to pass argument to editor?

Is there a way to pass argument to editor?

sadamiqbalsadamiqbal Posts: 18Questions: 6Answers: 0

I have a select with a plus button next to it to add additional option to that select. So, when i press the plus button, it will trigger the editor an pre-populated the form which has been successful thanks to your help. When the form closes, i need to select that particular select option which has just been created to be selected. The issue arise when a have multiple selects, DT Editor will not know which selects to set unless specified. Ideally i am looking for a way to tell the editor which select is activating the Editor and when Editor closes, set the triggered select. Do you think this is possible? If you have any idea which can help, please feel free to share. I appreciate you time and effort. thks in advance.

This question has an accepted answers - jump to answer

Answers

  • sadamiqbalsadamiqbal Posts: 18Questions: 6Answers: 0

    For example, telling the Editor which button/ name/ Id triggered the create action.

    Your help or advice will be of great help

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    So this is basically a case of keeping track of which select was used to trigger Editor? I don't think you want or need to use any of Editor's API for this, but you could do it with simple Javascript variables and possibly a few of Editor's events (open and close):

    var selectValue;
    
    editor.on( 'open', function () {
      selectValue = $('#mySelect').val();
    } );
    
    editor.on( 'close', function () {
      if ( selectValue === '...' ) {
        ...
      }
    } );
    

    Does that helps?

    Allan

  • sadamiqbalsadamiqbal Posts: 18Questions: 6Answers: 0

    var selectValue;
    userVariablesEditor.on('close', function (e, o)// reset value created from call flow trigger
    {
    var selectorToSet; //reset the autocomplete select value;
    });

    This what i have used, it works, but you any of you guys out there see something odd please lets me know.

    I declared a global variable, on if (data.action === 'create'){...
    ...
    if (selectorToSet)
    {
    selectorToSet.ComboboxPlugin('value', id); //set the combo value to the created id
    }
    }
    ...
    ...

  • sadamiqbalsadamiqbal Posts: 18Questions: 6Answers: 0

    Thanks a lot Allan, u give me lots of brilliant ideas

This discussion has been closed.