Add prependLabel() method in ActionContext

label() method appends label after passed element (useful for checkboxes). Add
a new mathod to prepend label before element (useful for input fields). Update
the JS API documentation.

Change-Id: I839fc7d38eca55d351074d01ffb2758bb538903e
This commit is contained in:
David Ostrovsky 2013-08-19 09:09:17 +02:00
parent 1cdfa1fdc8
commit a1067a3b04
2 changed files with 10 additions and 0 deletions

View File

@ -385,6 +385,10 @@ functions to make working with DOM based widgets less painful.
and the string `label`. Used to wrap a checkbox with its label,
`label(checkbox(), 'Click Me')`.
* `prependLabel(label, c)`: a new `<label>` element wrapping element `c`
and the string `label`. Used to wrap an input field with its label,
`prependLabel('Greeting message', textfield())`.
* `textarea(options)`: new `<textarea>` element. The options
object may optionally include `rows` and `cols`. The textarea
comes with an onkeypress handler installed to play nicely with

View File

@ -62,6 +62,12 @@ public class ActionContext extends JavaScriptObject {
e.appendChild(doc.createTextNode(label));
return e;
},
prependLabel: function(label,c) {
var e = doc.createElement('label');
e.appendChild(doc.createTextNode(label));
e.appendChild(c);
return e;
},
span: function() {
var e = doc.createElement('span');
for (var i = 0; i < arguments.length; i++)