X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=public%2Fedit_table.js;h=5c8d00dbe7f9058378debdc55393ff31b01f2a1e;hb=6c9f1ebf05caa1867171b079c613bdacab1e8ee4;hp=89c202ac3879d41618edea436d1c735a04dd5073;hpb=0f8e02eca7a102c65a4f077011cd3f7e6e91143b;p=MojoFacets.git
diff --git a/public/edit_table.js b/public/edit_table.js
index 89c202a..5c8d00d 100644
--- a/public/edit_table.js
+++ b/public/edit_table.js
@@ -16,20 +16,26 @@ var cell_blur = function() {
var x = $(this).parent().attr('cellIndex');
var y = $(this).parent().parent().attr('rowIndex');
- var content = $(this).val();
-// $(this).replaceWith( content );
+ var new_content = $(this).val();
+// $(this).replaceWith( new_content );
var name = $('table tr th:nth('+x+') > a').text();
- console.info( x, y, _row_id, name, content );
+ console.info( x, y, _row_id, name, new_content );
var update = $(this);
$.post( '/data/edit', {
path: document.title, _row_id: _row_id,
- name: name, content: content
- } , function(data) {
- console.debug( 'server data', data );
- var vals = content.split('¶');
+ name: name, new_content: new_content
+ } , function(data, textStatus) {
+ console.debug( 'data:', data, 'status:', textStatus );
+ if ( ! data ) {
+ data = new_content; // fallback to submited data for 304
+ } else {
+ if ( $('a.save_actions').length == 0 )
+ $('a.actions').before('save')
+ }
+ var vals = data.split('¶');
data = vals.join('¶');
update.replaceWith( data );
});
@@ -41,14 +47,14 @@ var cell_click = function(event) {
, event
, $(this).text()
);
- var content = $(this).text() // we don't want para markup
+ var new_content = $(this).text() // we don't want para markup
.replace(/^[ \n\r]+/,'')
.replace(/[ \n\r]+$/,'')
;
-console.debug( 'content', content );
- var rows = content.split('¶').length * 2 + 1;
+console.debug( 'new_content', new_content );
+ var rows = new_content.split('¶').length * 2 + 1;
var textarea = $('');
- textarea.val( content );
+ textarea.val( new_content );
$(this).html( textarea );
textarea.focus();
textarea.blur( cell_blur )