html helpers

8 views
Skip to first unread message

murray3

unread,
May 1, 2009, 7:24:53 PM5/1/09
to web2py Web Framework
If I have a page with
<h3>{{=A(comment.title.upper(),_href=URL
(r=request,f='edit_comment',args=[comment.id]))}} </h3

if I want to put edit_comment in an iframe and change the above code
so it refreshes the iframe and passes the args=[comment.id] to the
iframe, what is the syntax?

I have a list of links and as each is clicked I want an onclick event
to dynamically update the iframe page.

any help appreciated.
Chrism

mdipierro

unread,
May 2, 2009, 5:50:52 PM5/2/09
to web2py Web Framework
I am guessing you want

<iframe src="{{=URL(r=request,f='edit_comment',args=comment.id))}}"></
iframe>

Massimo

murray3

unread,
May 2, 2009, 6:14:17 PM5/2/09
to web2py Web Framework
Thanks Massimo,
I already have the iframe code working as per your suggestion on a
page.

What I would like to do is refresh the iframe when I click on a link
on the main page the
iframe is embedded within.

Also the link should pass the args to the iframe so that the correct
db rows are shown.

The links are the headers for discussion threads, when one is clicked
the iframe should show
the threads under that header

I have this javascript code which will refresh an iframe as I could
not find out how to do
it with jQuery:

<script type="text/javascript">
function refreshiframe(el){
var f =document.getElementById(el)
var rsrc = f.src
f.src="about:blank"
f.src=rsrc
}
</script>

What I want to do is use this or similar to refresh but parse the args
to the iframe
so it refreshes and shows correct db rows.

here is html I am using:

<table>
<tr>
<td>
{{for comment in comments:}}
<h2></h2>
<p>
<h3>
{{=A(comment.title.upper(),_href=URL(r=request,f='ii',args=
[comment.id]),_onclick="iframerefresh(ii)")}} </h3>

</p>
<p> posted by {{=comment.author_alias}} on {{=comment.timestamp}}
</p>
{{pass}}
{{=form}}
</td>
<td>
<h2></h2>
<iframe name="ii" id="ii" scrolling=" no" height="600"
width="500" frameborder: 0" src="{{=URL
(r=request,f='edit_comment',args=[comment.id])}}"></iframe>
</td>
</tr>
</table>

obviously my code - href=URL(r=request,f='ii',args=
[comment.id]),_onclick="iframerefresh(ii)"
is incorrect but not sure what synatx should be??

thanks
Chrism

mdipierro

unread,
May 2, 2009, 7:11:34 PM5/2/09
to web2py Web Framework
I suggest you use jQuery. This should work

<iframe src="...." id="myiframe"></iframe>
<a href="#null" onlick="$('#myiframe').attr('src','{{=URL
(....)}}');">click me to refresh iframe</a>

dlypka

unread,
May 2, 2009, 7:15:08 PM5/2/09
to web2py Web Framework
I think there is an array of frames in the DOM and you have to
window.open with a target to the desired array element.
I think you have to use window.open() or else set .location - I have
done this before but do not recall exactly.
> > > Chrism- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages