1 Form
.Methods
.serialize = function(form
, getHash
, buttonPressed
) {
2 var elements
= Form
.getElements(form
).reject(function(element
) {
3 return ['submit', 'button', 'image'].include(element
.type
);
6 if (buttonPressed
|| (buttonPressed
= form
.getElementsBySelector('*[type=submit]').first()))
7 elements
.push(buttonPressed
);
9 return Form
.serializeElements(elements
, getHash
);
16 initialize : function(options
) {
17 this.options
= Object
.extend({
18 evaluateScripts
: true
21 _makeRequest : function(options
) {
22 if (options
.update
) new Ajax
.Updater(options
.update
, options
.url
, options
);
23 else new Ajax
.Request(options
.url
, options
);
29 Remote
.Link
= Behavior
.create({
30 onclick : function() {
31 var options
= Object
.extend({ url
: this.element
.href
, method
: 'get' }, this.options
);
32 return this._makeRequest(options
);
36 Object
.extend(Remote
.Link
.prototype, Remote
.Base
);
38 Remote
.Form
= Behavior
.create({
39 onclick : function(e
) {
40 var sourceElement
= Event
.element(e
);
42 if (sourceElement
.nodeName
.toLowerCase() == 'input' &&
43 sourceElement
.type
== 'submit')
44 this._submitButton
= sourceElement
;
46 onsubmit : function() {
47 var options
= Object
.extend({
48 url
: this.element
.action
,
49 method
: this.element
.method
,
50 parameters
: Form
.serialize(this.element
, false, this._submitButton
)
52 this._submitButton
= null;
53 return this._makeRequest(options
);
57 Object
.extend(Remote
.Form
.prototype, Remote
.Base
);