1 $.fn.editable.defaults.ajaxOptions = {type: 'post', dataType: 'json'};
2 $.fn.editable.defaults.send = 'always';
4 // Default for editing is popup. I experimented with inline which is a little
5 // nicer in that it shows up right under the mouse instead of nearby. However,
6 // the inline box is taller than the regular content, which causes the page
7 // layout to shift unless we make the table rows tall, which leaves a lot of
8 // wasted space when not editing. Also inline can get cut off if the page is
9 // too narrow, when the popup box will just move to do the right thing.
10 //$.fn.editable.defaults.mode = 'inline';
12 $.fn.editable.defaults.success = function (response, newValue) {
13 $(document).trigger('editable:success', [this, response, newValue]);
16 $.fn.editable.defaults.params = function (params) {
18 var key = params.pk.key;
19 a.id = $(this).attr('data-object-uuid') || params.pk.id;
20 a[key] = params.pk.defaults || {};
21 // Remove null values. Otherwise they get transmitted as empty
22 // strings in request params.
24 if (a[key][i] == null)
27 a[key][params.name] = params.value;
29 a['_method'] = 'post';
36 $.fn.editable.defaults.validate = function (value) {
37 if (value == "***invalid***") {
38 return "Invalid selection";
43 on('ready ajax:complete', function() {
44 $('#editable-submit').click(function() {
49 success: function(response, newValue) {
50 // If we just created a new object, stash its UUID
51 // so we edit it next time instead of creating
52 // another new object.
53 if (!$(this).attr('data-object-uuid') && response.uuid) {
54 $(this).attr('data-object-uuid', response.uuid);
57 $(this).editable('option', 'url', response.href);
62 on('hidden', function(e, reason) {
63 // After saving a new attribute, update the same
64 // information if it appears elsewhere on the page.
65 if (reason != 'save') return;
66 var html = $(this).html();
67 var uuid = $(this).attr('data-object-uuid');
68 var attr = $(this).attr('data-name');
71 $("[data-object-uuid='" + uuid + "']" +
72 "[data-name='" + attr + "']").each(function() {
80 $.fn.editabletypes.text.defaults.tpl = '<input type="text" name="editable-text">'
82 $.fn.editableform.buttons = '\
83 <button type="submit" class="btn btn-primary btn-sm editable-submit" \
84 id="editable-submit"><i class="glyphicon glyphicon-ok"></i></button>\
85 <button type="button" class="btn btn-default btn-sm editable-cancel" \
86 id="editable-cancel"><i class="glyphicon glyphicon-remove"></i></button>\