You cannot call the javascript from the controller. The js calls the controller, the controller responds with other js that gets executed by the browser.
On Jul 10, 12:34 pm, Julius Minka <[email protected]> wrote: > Massimo, > I can see following: > > 1. in Jquery documentation: > html(val) > Set the html contents of every matched element. This property is not > available on XML documents (although it will work for XHTML documents). > > 2. in current svn trunk in web2py_ajax.html something like this: > function ajax(u,s,t) { > var query=""; > for(i=0; i<s.length; i++) { > if(i>0) query=query+"&"; > > query=query+encodeURIComponent(s[i])+"="+encodeURIComponent(document.getElementById(s[i]).value); > } > jQuery.ajax({type: "POST", url: u, data: query, success: > function(msg) { if(t==':eval') eval(msg); else > document.getElementById(t).innerHTML=msg; } }); > > } > > BUT: > I still do not understand, how it should help me to call javascript > function from controller. > Can you please explain it more? > Julius > > mdipierro wrote / napísal(a): > > > With the latest trunk you can do > > > <intput name="value" id="value" /> > > <button onclick="ajax('callback',['value'],':eval')">click me</button> > > <div id="target"></div> > > > def callback(): > > value=request.vars.value > > return "jQuery('#target').html(%s)" % repr(str(value)) > > > when you click the button it sends the value of value to the callback > > function. The function returns a jQuery string and the clients runs > > it. The trick here is ajax(...,':eval') which is defined by web2py. > > > On Jul 10, 8:56 am, Julius Minka <[email protected]> wrote: > >> Hi all, > > >> I have a javascript function in html file which is usually called from > >> onclick event in the same file. It works fine. > >> However I would like to call this javascript function from a controller. > > >> More precise description: > >> after clicking an element in the page, the flow goes to controller. > >> There I decide which dialog to display (I have it working to this > >> point), but it is defined again in html file as jquery dialog opening > >> with .dialog("open"); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

