Just from a quick glance
update is a div so the line
this.updated.set('value', .....)
should be:
this.updated.set('html', .....)
form elements set the value not divs.
Also, setting the disabled property on a div makes no sense (again, it's not
a form element).
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Providence
Sent: Monday, March 15, 2010 11:13 PM
To: MooTools Users
Subject: [Moo] Trying to learn classes
I am trying to create a class and having some problems getting it to
work. In fact, only part of it is working. The class seems to send the
ajax request I want, but it doesn't set the values of some elements
and doesn't stop the submission of the form. Below is the class I am
trying to create
var Form_request = new Class({
Implements: [Events],
initialize: function(form, update) {
this.form = $(form);
this.updated = $(update);
this.attach();
},
attach: function() {
this.form.addEvent('submit', function(e) {
e.stop;
this.form.set('send', {
onRequest: function() {
this.updated.set('value',
'Sending...').set('disabled', true);
}.bind(this),
onSuccess: function(data) {
if (data.test('^required')) {
this.updated.set('value',
'Continue...').set('disabled', false);
} else {
console.log('test');
}
}
}, this).send();
}.bind(this));
}
});
var FR = new Form_request('form_id', 'update');
And here is the html:
<div id="update"></div>
<form id="form_id" method="post">
<input type="text" id="date" name="first_name"><br />
<input type="text" name="last_name"><br />
<input class='submit' type="submit">
</form>
Here it is at mooshell
http://mootools.net/shell/3b5ZQ/1/