This project is archived and is in readonly mode.

#1215 ✓resolved
boppy

Combining options.filter and options.update in Request.HTML [1.3.1/core/Request.HTML]

Reported by boppy | April 26th, 2011 @ 08:58 PM | in 2.0 (closed)

Line-Count based on
https://github.com/mootools/mootools-core/blob/3c3e54c33e1fd9f89f5470ece6b5aa5b2e155c79/Source/Request/Request.HTML.js

Currently it is not possible to take the short way to include a subpart into an other:

var myRequest = new Request.HTML({
    url: 'ajax.php',
    update: document.id('content'),
    filter: '#content_element'
}).get(page: 1234);

This will set the HTML of $('content') to the COMPLETE output of ajax.php?page=1234.

To enhance I changed [Lines 45ff (in my 1.3.1-Core (plain/nc) it's 5029)]:

        if (options.filter) response.tree = response.elements.filter(options.filter);
        if (options.update) document.id(options.update).empty().set('html', response.html);
        else if (options.append) document.id(options.append).adopt(temp.getChildren());
        if (options.evalScripts) Browser.exec(response.javascript);

to

        if (options.filter) response.tree = response.elements.filter(options.filter);
/*<*/   if (options.update && response.tree.length==1) document.id(options.update).empty().grab(response.tree[0]);
        else /*>*/ if (options.update) document.id(options.update).empty().set('html', response.html);
        else if (options.append) document.id(options.append).adopt(temp.getChildren());
        if (options.evalScripts) Browser.exec(response.javascript);

(I placed the injected code between /*<*/ and /*>*/)

It will inject the filters Output (actually $('content_element')) to the options.update Element if there is only one single element to be injected.

PS: I hope this is the right place to place this request

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Pages