简体   繁体   中英

How to update multiple elements with one MooTools Request.HTML call

Does anyone know if, using one Request.HTML call from MooTools, it is possible to somehow update more than one element in a webpage? The current call I have is:

var req = new Request.HTML({update: $('content')}).get('../latest_events');

This updates the content div in my page with the "../latest_events" page. Is there a way to update other divs with the "../latest_events" page using this same call, or do I have to just use separate calls?

Yes, you can do whatever you want with the request data after you've obtained it. Just add a success event function to your Request.HTML options and handle the responseText by hand. Documentation about the events available to Request.HTML is available here:

http://mootools.net/docs/core/Request/Request

Always remember to check if a Mootools class extends another (it'll be noted at the top of the class). Typically you'll have to go all the way up the class tree to find the basic events associated with the class (as is the case with Request.HTML).

You should use the addRequests Method from Request.Queue Class from mootools :

var req = new Request.HTML({update: $('content')}).get('../latest_events');
var req2 = new Request.HTML({update: $('content2')}).get('../new_events');
myRequestQueue.addRequests({
    req1: req,
    req2: req2
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM