0

I have mentioned a method inside a JavaScript object in dojo aspect like

aspect.before(objectname, "someMethod", function(arg1, arg2) {
        console.warn("aspect.before: ", arg1, arg2);
    });

is it possible to call a regular JavaScript function like

 function cn(){
      alert("Hello");
    }

in dojo aspect

1 Answer 1

1

This is more or less a duplicate of : is it possible to use dojo aspect on a method with no target?

In your case, you have to use window object :

function aMethod() {
  console.log('the method');
}

require(['dojo/aspect'], function(aspect) {



  aspect.before(window, 'aMethod', function() {
    console.log('this runs before');
  });


});

aMethod();
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.