Project

General

Profile

« Previous | Next » 

Revision 52e114a6

Added by Ohad Levy over 12 years ago

  • ID 52e114a6796cbdd3ad8adb3eafe9936844bd0797

fixes #1182 - added inline editing

View differences:

public/javascripts/application.js
}]
});
};
$(document).ready(function() {
var common_settings = {
method : 'PUT',
submit : 'Save',
indicator : "<img src='../images/spinner.gif' />",
tooltip : 'Click to edit..',
placeholder : 'Click to edit..',
submitdata : {authenticity_token: AUTH_TOKEN, format : "json"},
onsuccess : function(data) {
var parsed = $.parseJSON(data);
$(this).html(parsed[$(this).attr('name').split("[")[0]][$(this).attr('data-field')]);
},
onerror : function(settings, original, xhr) {
original.reset();
var error = $.parseJSON(xhr.responseText)["errors"]
$.jnotify(error, { type: "error", sticky: true });
}
};
$('.edit_textfield').each(function() {
var settings = {
type : 'text',
name : $(this).attr('name'),
};
$(this).editable($(this).attr('data-url'), $.extend(common_settings, settings));
});
$('.edit_textarea').each(function() {
var settings = {
type : 'textarea',
name : $(this).attr('name'),
rows : 8,
cols : 36
};
$(this).editable($(this).attr('data-url'), $.extend(common_settings, settings));
});
});

Also available in: Unified diff