Update div after form Submit Mootools 1.1 to Mootools 1.4.1

I have a Mootools 1.11 script that updates the div after submitting the form, the form sends data to form.php and returns a message like "submitted form".

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'); } }); }); 

Hope someone helps me. Thanks

+4
source share
1 answer
Constructor

new Event() does not work. Events are now normalized 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 better do:

 $('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(); }); 

jsfiddle is currently playing, but when it returns: http://jsfiddle.net/mFRZP/

Element helpers are all beautiful and beautiful for quick work, but you really want control and clarity to know what you are doing.

You cannot use Request.HTML when you can use Request.

+4
source

Source: https://habr.com/ru/post/1489923/


All Articles