reednj/InlineEditor — pull request #5 by PeteAUK (2011-11-09 14:53:02+00:00)
Title: Modification to the way ID is found and created InlineEditorGroup

Modified so that if ID is passed within a data object then this will be used as the data id if one does not exist. e.g.

new InlineEditor(someObject, {
'url': 'myurl.php',
'data': {
'id': 10
}
});

The value of the field is given a default value if it exists.

After saving, any JSON result is passed back to the onSuccess method/function.

Added a getValue method. This retrieves the value of the field and returns it an object, based on the id passed.

Extend the Object method to have a "make" function. This allows you to pass a key & value and it returns an object with this. Normally it is not possible to set the key of an object programmatically.

---

InlineEditorGroup.

This object can be used to collect a number of InlineEditors together and retrieve the values for all of the items. This works very well if you set the url to null and can create a “form” of InlineEditors

It consists of five methods:
InlineEditorGroup.InlineEditor(el, options) – add a new InlineEditor to the grouping.
InlineEditorGroup.Combo(el, options) – add a new InlineEditor.Combo to the grouping.
InlineEditorGroup.Textarea(el, options) – add a new InlineEditor.Textarea to the grouping.
InlineEditorGroup.toObject() – retrieve an object of id: value pairs for all editors within the grouping.
InlineEditorGroup.toQueryString() – retrieve the id, value pairs for all editors within the grouping as a query string.

e.g.

InlineEditorGroup.InlineEditor($('text1'), {url: null, hide_buttons: true, data_id: 'text1'});
InlineEditorGroup.InlineEditor($('text2'), {url: null, hide_buttons: true, data_id: 'text2'});
InlineEditorGroup.Combo($('dropdown'), {url: null, hide_buttons: true, data_id: 'dropdown'});

InlineEditorGroup.toObject();

Would result in:
{
text1: "some value",
text2: "some value",
dropdown: "some value"
}