Jump to content

Cant invoke function from click


Gerhard

Recommended Posts

<!-- -----  Info View --------------- -->    

<div >
  <span class="col-xs-2"><button onclick="drawEnergyGraph()">Energy</button></span>
  <span class="col-xs-2"><button onclick="drawBatteryGraph()">Battery</button></span>
  <span class="col-xs-2"><button onclick="drawTempGraph()">Temperature</button></span>
  <span class="col-xs-6"></span>
</div>
<div id="chartFrame" ><svg id="chart1"></svg></div>

    <script>
      var chart;
      var data;
        
      function drawEnergyGraph ()
        {           
          alert('Energy')
        }
        
      function drawBatteryGraph ()
        {
          alert('Battery')  
        }
        
      function drawTempGraph ()
        {
          alert('Temperature')                
        }

Hi,

have the above code. Works on a full page, no Problem.

After moving from a MPA to a SPA using ng-route, everything seems to be ok. The partial views coming up, but now I can't fire the function.

The Browsers Debugger told me, that the function I want to call on click isn't defined, but sorry I can see the function ....

Any idea to help a newbee.

 

Thanks

 

With best regards

 

Gerhard

 

 

Link to comment
Share on other sites

we would need to see the actual code you are using now, though. also, you mention ng-route, so you are using Angular, yes?

Link to comment
Share on other sites

Hi,

yes, I use AngularJS.

I attach the wohle code, no Problem. I do some tests and eleminated all stuff not related with this issue, so the code doesn't make sense, it just tries to invoke a function.

 

If you were able to get it running, follow 'Route1 and on 'Page-1" is the test function and the test button.

 

With best regards

 

Gerhard

 

PS: Din't get email notification, have clicked on 'Follow this topic' ...

Website.zip

Link to comment
Share on other sites

One problem is you have <script>...</script> tags inside a js files, these are HTML tags and are only required in web page itself to distinguish what is placed within them. they not required in js files, as with <style></style> tag are not required in css file.

Link to comment
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
×
×
  • Create New...