简体   繁体   中英

Update div after form send Mootools 1.1 to Mootools 1.4.1

I have this Mootools 1.11 script that is updating div after the form is submited , form sends data to 'form.php' file and it returns a message like "form sent."

I would like to convert it to mootools 1.4.1

Mootools 1.11

    $('myform').addEvent('submit', function(e) {

        new Event(e).stop();
        var log = $('log_res').empty().addClass('ajax-loading');
        this.send({
            update: log,
            onComplete: function() {
                log.removeClass('ajax-loading');

            }
        });
    });

I hope someone help me. Thanks

new Event() constructor won't work. Events are now normalised automatically. just e.stop();

update : does not work outside of Request.HTML . http://mootools.net/docs/core/Request/Request.HTML - also this.send(URL); - you are better off doing:

$('myform').addEvent('submit', function (e) {
    e.stop();

    var log = $('log');

    new Request.HTML({
        url: this.get('action'),
        data: this,
        update: log,
        onRequest: function(){
            log.addClass('ajax-loading').empty();
        },
        onComplete: function(){
            log.removeClass('ajax-loading');
            // can also do:
            // log.set('html', this.response.text); 
        }
    }).send();
});

currently jsfiddle is playing up but when it comes back: http://jsfiddle.net/mFRZP/

Element helpers are all fine and lovely for quick jobs but you really want control and clarity to know what you are doing.

No need to use Request.HTML when you can use Request.

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