You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2008/03/26 14:51:03 UTC
svn commit: r641308 -
/incubator/sling/trunk/sling/ujax/src/main/resources/ujax/ujax.js
Author: bdelacretaz
Date: Wed Mar 26 06:50:58 2008
New Revision: 641308
URL: http://svn.apache.org/viewvc?rev=641308&view=rev
Log:
improvements to ujax._setFormValues()
Modified:
incubator/sling/trunk/sling/ujax/src/main/resources/ujax/ujax.js
Modified: incubator/sling/trunk/sling/ujax/src/main/resources/ujax/ujax.js
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/ujax/src/main/resources/ujax/ujax.js?rev=641308&r1=641307&r2=641308&view=diff
==============================================================================
--- incubator/sling/trunk/sling/ujax/src/main/resources/ujax/ujax.js (original)
+++ incubator/sling/trunk/sling/ujax/src/main/resources/ujax/ujax.js Wed Mar 26 06:50:58 2008
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -316,28 +316,35 @@
while (elems.length > i) {
var elem=elems[i];
var a=elem.name;
- if (a.indexOf(formfieldprefix)==0) {
+
+ if (a.indexOf("/")==0) {
+ var nodepath=a.substring(0,a.lastIndexOf("/"));
+ var propname=a.substring(a.lastIndexOf("/")+1);
+ var node=ujax.getContent(nodepath);
+ var propval=node[propname];
+ } else if (a.indexOf(formfieldprefix)==0) {
var propname=a.substring(formfieldprefix.length);
- if (tree[propname]) {
- if (elem.type == "file") {
- // cannot edit uplodaded files for now
- } else if (elem.type == "checkbox") {
- var vals;
- if (typeof(tree[propname])=="object") vals=tree[a.substring(2)];
- else {
- vals=new Array();
- vals[0]=tree[propname];
- }
- var j=0;
- while (vals.length > j) {
- if (vals[j] == elem.value) elem.checked=true;
- j++;
- }
- } else {
- elem.value=tree[propname];
- }
- }
-
+ var propval=tree[propname];
+ }
+
+ if (propval) {
+ if (elem.type == "file") {
+ // cannot edit uplodaded files for now
+ } else if (elem.type == "checkbox") {
+ var vals;
+ if (typeof(propval)=="object") vals=propval;
+ else {
+ vals=new Array();
+ vals[0]=propval;
+ }
+ var j=0;
+ while (vals.length > j) {
+ if (vals[j] == elem.value) elem.checked=true;
+ j++;
+ }
+ } else {
+ elem.value=propval;
+ }
}
i++;
}