My app has some restaurants. I have a restaurant for each page where you can comment or leave a review. I'm using timer_tick to query if there are newer reviews after you open the page every 10seconds. If there is, timer_tick returns those reviews. The problem I'm having is when I have 2 restaurants pages open and comment in Restaurant A, the function timer_tick returns a new comment to Restaurant B
Did i made myself clear? On Sep 1, 3:28 pm, "mr.freeze" <nat...@freezable.com> wrote: > The value that you return from timer_tick will be eval'd by default. > What do you want to do with the value from your db query in the UI? > > On Sep 1, 9:17 am, Francisco Costa <m...@franciscocosta.com> wrote: > > > > > > > > > please be more specific.. > > > In timer_tick I do a db query, and I need to pass a value to succeed > > on that query. > > I could save the value in the session.value, but that wouldn't work > > out when there are 2 pages open, that's why I want to pass it to > > timer_tick > > > On Sep 1, 3:13 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > > You can't pass arguments to exposed functions. Use the method(s) I > > > outlined instead: > > > def timer_tick(): > > > if request.vars.my_var_passed_in_data: > > > .... > > > > I can be more specific if you tell me what you are trying to pass to > > > timer_tick. > > > > On Sep 1, 8:57 am, Francisco Costa <m...@franciscocosta.com> wrote: > > > > > But i want to pass a value to the function timer_tick > > > > something like this > > > > > callback = js.call_function(timer_tick(arg)) > > > > > but the function > > > > def timer_tick(arg): > > > > > doesn't load properly > > > > > On Sep 1, 2:02 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > > > > If you're talking about the Client Tools module located > > > > > here...http://www.web2pyslices.com/main/slices/take_slice/8 > > > > > ...there is an 'data' parameter in event.listen that you can use. It > > > > > can be a jQuery selector (default is 'form:first') and will show up in > > > > > request.vars. If you don't need to grab the value of an element, then > > > > > you can use the 'args' parameter and it will show up in request.args. > > > > > > On Sep 1, 6:44 am, Francisco Costa <m...@franciscocosta.com> wrote: > > > > > > > i have this autorefresh > > > > > > > form = SQLFORM.factory(Field('AutoUpdates', > > > > > > requires=IS_IN_SET(['On','Off']),default="On", > > > > > > widget=SQLFORM.widgets.radio.widget)) > > > > > > refresh.ready(jq("input[type='submit']").hide()()) > > > > > > callback = js.call_function(timer_tick) > > > > > > refresh.ready(js.timer(callback,10000)) > > > > > > event.listen('change',"input[name='timer']",timer_tick) > > > > > > > the thing is i want to call the function timer_tick with an argument > > > > > > and the use it like this > > > > > > > def timer_tick(arg): > > > > > > arg_passed=arg > > > > > > > How I do the js.call_function() and the event.listen() ?