ddeadlink
ddeadlink

Reputation: 247

How can i have an access to style object in another function

How can i have an access to style object in another function. I've got this part

...
onOk: function() {

          var style = new CKEDITOR.style({
            element: 'p',
            styles: {
              //some styles
            },
            spaceFlag: 'superFlag'
          });
          editor.applyStyle( style );
    },
    onShow: function(){
    // i want to get here spaceFlag
 }
..

Upvotes: 0

Views: 32

Answers (1)

John Vandivier
John Vandivier

Reputation: 2426

It looks like you do not have one function which calls the other. Instead, they are both siblings who are children of the parent context. So define your styles in the parent context:

var styleOptions = {
        element: 'p',
        styles: {
          //some styles
        },
        spaceFlag: 'superFlag'
    }, onOk: function() {
        var style = new CKEDITOR.style(styleOptions);
        editor.applyStyle( style );
    },
    onShow: function(){
        // i want to get here spaceFlag
        styleOptions.spaceFlag
    },
...

Here's a separate snippet you can run out-of-the-box:

    function logMe() {
        var styleOptions = {
            element: 'p',
            styles: {
              //some styles
            },
            spaceFlag: 'superFlag'
        };
        console.log(styleOptions.spaceFlag);
    }
    logMe();

Upvotes: 1

Related Questions