Jump to content
Gerhard

Cant invoke function from click

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

 

 

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...