problems refreshing component from link in svg image

93 views
Skip to first unread message

monotasker

unread,
Feb 22, 2012, 5:18:15 PM2/22/12
to web...@googlegroups.com
I'm using an svg image as a navigation map, with areas that can be clicked. I've got the interactivity working via an external javascript, but when I try to call web2py_component() I get an error telling me that web2py_component is not defined. I assumed that I could call it since this script is loaded after page load. I'm not sure where the problem lies, so here is how it's all set up:

This is my js function to refresh the component (in static/js/svg_interactions.js):

function go_there(evt){
    var tobj = evt.currentTarget;
    var oname = tobj.getAttribute('id');
    var the_url = "/paideia/exploring/index.load/?loc=" + oname
    web2py_component("/paideia/exploring/index.load","page")
}

This script is linked into the svg file (in the xml itself, as an immediate child of the svg element) like this: <script type="text/javascript" xlink:href="../js/svg_interactions.js" />

The function go_there() is called via the "onclick" attribute of any child entity in the svg file (onclick="go_there(evt)").

The svg file is embedded in a view like this: <embed src='{{=map_image}}' type='image/svg+xml' />

Again, everything is working nicely except that svg_interactions.js doesn't seem to be aware of web2py_component().

Thanks,

Ian

Anthony

unread,
Feb 22, 2012, 5:31:45 PM2/22/12
to web...@googlegroups.com
You're sure that web2py.js has been loaded into the page?

Anthony

unread,
Feb 22, 2012, 8:38:14 PM2/22/12
to web...@googlegroups.com
Maybe try:

top.web2py_component("/paideia/exploring/index.load","page")

or

window.parent.web2py_component("/paideia/exploring/index.load","page") 

Anthony


On Wednesday, February 22, 2012 5:18:15 PM UTC-5, monotasker wrote:

monotasker

unread,
Feb 29, 2012, 5:05:38 PM2/29/12
to web...@googlegroups.com
Hi Anthony,

Sorry for the delayed response. Adding window.parent did the trick. Thanks.

Ian
Reply all
Reply to author
Forward
0 new messages