Permalink
Browse files

New data_id parameter added as shorthand for using {data:{id:'xxx'}}

  • Loading branch information...
1 parent 5733ff6 commit 5bb765bca58474c8bfc48f61f7c4906825113c0f @reednj committed Aug 12, 2011
Showing with 12 additions and 2 deletions.
  1. +2 −1 Docs/InlineEditor.md
  2. +2 −1 Source/InlineEditor.js
  3. +8 −0 Test/simpletest.html
@@ -15,7 +15,8 @@ InlineEditor Method: constructor {#InlineEditor:constructor}
### Options:
* url - (*string, optional*) url to send the save request to
-* data - (*object, optional*) extra data to send along with the save request
+* data - (*object, optional*) extra data to send along with the save request.
+* data_id - (*string, optional*) Sohrthand method to pass in {data:{id:'xxx' }} on the object
* empty_msg - (*string, optional*) the message to show when the element is empty. You can use html.
* hide_buttons - (*bool, optional*) hides the 'save' and 'cancel' buttons, use ENTER to submit, ESC to cancel.
* format - (*string, optional*) A format code of the type Nx where x is the number of decimal places to format with. Only use this if the data type is numerical.
@@ -32,6 +32,7 @@ var InlineEditor = new Class({
// set defaults...
this.options = options || {};
this.options.url = this.options.url || this.element.get('data-url');
+ this.options.data_id = this.options.data_id || this.element.get('data-id');
this.options.data = this.options.data || {};
this.options.empty_msg = this.options.empty_msg || this._empty_msg;
this.options.onSuccess = this.options.onSuccess || $empty;
@@ -169,7 +170,7 @@ var InlineEditor = new Class({
// set up the data to send to the server.
var request_data = $H({'value':new_value});
request_data.combine(this.options.data);
- request_data.include('id', this.element.get('data-id')); // if 'id' already exists it will not be overwritten
+ request_data.include('id', this.options.data_id); // if 'id' already exists it will not be overwritten
var save_req = new Request({
'url': this.options.url,
@@ -65,6 +65,12 @@
$('color-target').setStyle('background-color', new_value);
}
});
+
+ new InlineEditor('jsonpost', {
+ url: 'api/edittest.php',
+ method: 'POST',
+ data_id: '12'
+ });
}
}
@@ -116,6 +122,8 @@
<div class='editable' data-format='N3'>123456.12345</div>
+<div id='jsonpost'>hello, world</div>
+
</div>
</body>

0 comments on commit 5bb765b

Please sign in to comment.