Sorry, you could do one event handler with two ajax calls:
jQuery("#clickme").bind("click", function(e){
jQuery.ajax
({type:"POST",url:"/test/default/handle_1",data: jQuery
("form:first").serialize(),success: function(msg){jQuery("#div1").html
(msg);} });
jQuery.ajax
({type:"POST",url:"/test/default/handle_2",data: jQuery
("form:first").serialize(),success: function(msg){jQuery("#div2").html
(msg);} });
});
On Sep 28, 10:11 pm, "mr.freeze" <[email protected]> wrote:
> I just noticed you said different function calls. You would have to
> create two event handlers for the same event:
>
> jQuery("#clickme").bind("click", function(e){jQuery.ajax
> ({type:"POST",url:"/test/default/handle_1",data: jQuery
> ("form:first").serialize(),success: function(msg){jQuery("#div1").html
> (msg);} });});
> jQuery("#clickme").bind("click", function(e){jQuery.ajax
> ({type:"POST",url:"/test/default/handle_2",data: jQuery
> ("form:first").serialize(),success: function(msg){jQuery("#div2").html
> (msg);} });});
>
> or with Client Tools module:
>
> def two_callbacks():
> a = A("Click Me",_id="clickme")
> div1 = DIV(_id="div1")
> div2 = DIV(_id="div2")
> event.listen("click", a, handle_1, div1)
> event.listen("click", a, handle_2, div2)
> return dict(a=a,div1=div1,div2=div2)
>
> def handle_1():
> return "Handle 1: " + str(request.now)
> def handle_2():
> return "Handle 2: " + str(request.now)
>
> ...or update both in one callback...:
>
> div1 = DIV(_id="div1")
> div2 = DIV(_id="div2")
> def event_by_selector():
> a = A("Click Me",_id="clickme")
> event.listen("click", a, handle_1)
> return dict(a=a,div1=div1,div2=div2)
>
> def handle_1():
> return jq(div1).html("Div 1: " + str(request.now))() + \
> jq(div2).html("Div 2: " + str(request.now))()
>
> On Sep 28, 9:03 pm, weheh <[email protected]> wrote:
>
> > Is there a way to get an ajax script to update two different DIV ids
> > with one call? For instance, I want a link, that when clicked, will
> > cause two different DIVs, each with a unique id, to be updated by
> > different function calls. Is this possible?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---