Sign in to follow this  
Grid Trekkor

Javascript drill-down function is not defined

Recommended Posts

I'm dynamically creating some data:

month.dataset[2].data.push({ "value" : data.data[k].Hi.toString(), "link" : "JavaScript:displayDay(" + (k+1) + ")" });

k is the iterator.  Here is my displayDay function.  This does not work.  I get Uncaught ReferenceError: displayDay is not defined:

function displayDay(day) {
    console.log(day);
}

But this works:

month.dataset[2].data.push({ "value" : data.data[k].Lo.toString(), "link" : "JavaScript:console.log(" + (k+1) + ")" });

It logs the value to the console as it should. Any idea why the above function doesn't work?  Thank you.

Edited by Grid Trekkor

Share this post


Link to post
Share on other sites

EDIT:  I did get it to work by moving displayDay() to the top of the JS file (outside my Angular controller), but then Angular no longer has access to it, so I'm not sure how to fix that.

 

On the other hand, if I define the function using $scope, then I get the same error: Uncaught ReferenceError: $scope is not defined - fusioncharts.js:155

Edited by Grid Trekkor

Share this post


Link to post
Share on other sites

Hi, thank you for the reply.  Yes, I've sourced the AngularJS plugin locally like this:

<script type="text/javascript" src="/javascripts/angular.min.js"></script>
<script type="text/javascript" src="/javascripts/jquery.min.js"></script>
<script type="text/javascript" src="/javascripts/fusion/fusioncharts.js"></script>
<script type="text/javascript" src="/javascripts/fusion/angular-fusioncharts.min.js"></script>

I managed to get it working by adding jQuery, but it seems like I shouldn't have to do that.

Edited by Grid Trekkor

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this