Search code examples
javascripttinymcetinymce-4

How to hide an element in TinyMCE popup window?


I'm trying to build a custom plugin based on a stock TinyMCE 4 image plugin. It'll have two drop-downs. When user clicks the first one - I'd like to hide the second one (css style display: none;).

Here is a bit of code that adds drop-downs in the initializer:

        targetTest1ListCtrl = {
            name: 'test1',
            type: 'listbox',
            label: 'Test1',
            values: buildValues('target_list', 'target', InputDataArray),
            onClick: function(e) {
                    //code I'm looking for
            },
        };
generalFormItems.push(targetTest1ListCtrl);
        targetTest2ListCtrl = {
            name: 'test2',
            type: 'listbox',
            label: 'Test2',
            values: buildValues('target_list', 'target', InputDataArray2)
        };
generalFormItems.push(targetTest2ListCtrl);

Both drop-downs generate just fine, if I put alert in my onclick event - it's triggered perfectly fine, but in no way I can find how to access my test2 through the TinyMCE and change styling on it.


Solution

  • Found an answer:

    sampleElement = win.find('#test2')[0];
    sampleElement.hide();
    

    Where #test2 is #+name of your Ctrl.