Skip to content

Commit

Permalink
Merge remote branch 'core/jaction-form' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed Oct 27, 2010
2 parents 885c5b1 + eaf7ed1 commit 0637391
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions public/javascripts/jaction.js
Expand Up @@ -53,6 +53,37 @@
openclose: function() { this.toggle(); }
}

JForm = {
updateform: function(sel) {
var settings = sel ? sel.split(",") : [];
var url = settings.length > 0 ? settings[0] : document.location.pathname;
var container = settings.length > 1 ? settings[1] : $j(this[0].form).parent();
var frm = settings.length > 2 ? $j(settings[2]) : $j(this[0].form);
$j(this[0]).change(function() {
container.load(url, frm.serializeArray());
});
},

submitform: function(sel) {
var settings = sel ? sel.split(",") : [];
var url = settings[0];
var frm = $j(this[0]);
var container = settings.length > 1 ? settings[1] : frm.parent();

$j(this[0]).submit(function() {
var data = frm.serializeArray();
data.push({name: 'commit', value: 1});
$j.post(url, data, function(res, status, xhr) {
var contentType = xhr.getResponseHeader("Content-Type");
if(!(contentType && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) {
container.html(res);
}
});
return false;
});
}
}

JSetup = {
setup: function() {
$j("*[j-action]").each(function() {
Expand All @@ -65,6 +96,10 @@
var actfield = acts[i];
var sel = $j(elem).attr(actfield);
JAction[acts[i]].call(elem,sel);
} else if(JForm[acts[i]]) {
var actfield = acts[i];
var sel = $j(elem).attr(actfield);
JForm[acts[i]].call(elem,sel);
}
else if(JClick[acts[i]]) {
(function(actfield) {
Expand Down

0 comments on commit 0637391

Please sign in to comment.