Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redactor callbacks with current scope. #24

Open
sebastiansibelle opened this issue Oct 14, 2014 · 1 comment
Open

Redactor callbacks with current scope. #24

sebastiansibelle opened this issue Oct 14, 2014 · 1 comment

Comments

@sebastiansibelle
Copy link

How can I use Redactor callbacks while also having access to the current scope?

For example, if I want to change something on Keydown I should supply a keydownCallback as an option like in the provided example:

    redactorOptions.keydownCallback = function triggerKeydown(e){
        console.log("key down!");
    }

But if I want to update something related to the current scope how can I go about that whilst still using the redactorOptions method for supplying callbacks.

E.g. how would I do this?

    redactorOptions.keydownCallback = function triggerKeydown(e){
        scope.doSomething(e); // throws an error because scope is not available
    }

Thoughts?

@RogerQuiros
Copy link

@sebastiansibelle What i did to fix that was to have an external function calling the scope inside of it:

.config(function(redactorOptions) {
    redactorOptions.changeCallback = function (){
        externalMethod();
    };
});

And them in the plain javascript function this:

function externalMethod()
{
    var scope = angular.element(_JQUERY_("#elementWithController")).scope();
    scope.internalAngularMethod();
}

The "internalAngularMethod()" refers to any function o variable in the angular scope.

Notes that i have a no conflict version of JQuery ("JQUERY " = "$") at the top of the document, because the JQuery dolar sign gets in conflict with the dolar sign of angular. You may have a different (better) approach of this in your project.

var _JQUERY_ = $.noConflict();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants