I have created a codepen that draws on the canvas and used a javascript addEventListener to capture the mouse clicks. I think that not working properly is my issue. What would be the proper procedure to grab a codepen sample and serve it up in the framework properly?
I am still on the learning curve of how to use Web2Py but have simply been modifying the standard welcome app to play around. If any of the following steps are not the best way to do this please let me know. 1) under static/js I added a file called canvas.js which is the contents of the javascript codepen https://codepen.io/brian2222/pen/ZBJLyp 2) I added the following code to default/index.html (I left a few lines above and blelow my edit so it is easier to see the edits) The two key lines are the canvas and the script tag right below it. {{elif 'content' in globals():}} {{=content}} {{elif 'form1' in globals():}} <table><tr><td> <canvas id="canvas" width="400" height="400" style="border:solid 1px #ddd;display: block;left: 50%;margin: -200px -200px 0 -200px;position: absolute;top: 50%;"></canvas> <script src="{{=URL('static','js/canvas.js')}}"></script> </td><td> <h3>Read Voltage</h3> {{=form1}} <h3>Write Voltage</h3> {{=form2}} </td></tr> </table> <h3>Response Toolbar</h3> {{=response <https://plc-labs.net/examples/global/vars/response>.toolbar()}} {{else:}} {{=BEAUTIFY <https://plc-labs.net/examples/global/vars/BEAUTIFY>(response <https://plc-labs.net/examples/global/vars/response>._vars)}} 3) I already had the form1 and form 2 stuff working, so this is not part of the issue. My goal was to simply get the codepen working. The idea is that it draws the boxes and buttons and then allows one to click on them to change their color for now, ajax later will eventually make this useful. 4) The canvas is drawn the first time from the line: document.onload=reDraw(); This line of code is in the canvas.js file and so makes me think it runs fine so why isn't the next line? 5) The clicks are not captured with the event listener, the following line: canvas.addEventListener("click",myClick); 6) Although I am learning a lot at once, I do have confidence the Canvas stuff works as it works on codepen. And when served up statically from my own computers web server. 7)I am not at all familiar with how to use Bootstrap, is this js somehow stopping my event listener from running? Is there a good link/video to get an overview of how bootstrap works in the web2py framework specifically as this would be more valuable than learning bootstrap on its own? Thanks for the help -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.