I have a view with a button and a DIV
I am trying to have this 开发者_如何学Pythonkind of functionality:
if the button is clicked - a controller method is executed ( i have the method, db.insert, etc.) - if test (inside the controller method) is passed the button dissapears and the div appears ( I thought at using ajax - not to refresh the hole page)
whenever the page is refreshed the test has to be made again for the button to be visible or not
thanks
Something like this?
{{=DIV(A('click me',callback=URL('mycallback'),target="me"),_id="me")}}
def mycallback():
# do whatever you need to do
return DIV("I will appear in place of he link when you click")
I looked in more of your examples and I think my problem was simpler ( if there isn't any other solution) So what I did was I used eval:
button in view :
<input id="b_normal" type="button" value="normal" onClick="ajax('{{=URL('db_test')}}',[],':eval')" />
and the controller method:
def db_test()
#tests and updates return "jQuery('#b_normal').fadeOut();jQuery('#commDiv').show();"
for further refresh i used jquery, in view:
jQuery(document).ready(function(){
var flag = '{{=flag_normal}}'; if(flag == 'da') jQuery('#b_normal').hide(); else jQuery('#commDiv').hide(); });
where *flag_normal* is sent by the main controller
I hope this is not too inefficient and if so, useful
精彩评论