Skip to content

Commit

Permalink
Merge pull request #200 from mattlibera/hotfix/fix-editing
Browse files Browse the repository at this point in the history
Fix broken post/comment editing
  • Loading branch information
marktopper authored Apr 4, 2018
2 parents d9253c0 + a5bb778 commit 46d4562
Showing 1 changed file with 38 additions and 37 deletions.
75 changes: 38 additions & 37 deletions public/assets/js/chatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,49 @@ $('document').ready(function(){
// $('#textbox1').val($(this).is(':checked'));
});

});
// Enable a function $.form to submit a dynamic form
jQuery(function($) {
$.extend({
form: function(url, data, method) {
if (method == null) method = 'POST';
if (data == null) data = {};

// Enable a function $.form to submit a dynamic form
jQuery(function($) { $.extend({
form: function(url, data, method) {
if (method == null) method = 'POST';
if (data == null) data = {};

var form = $('<form>').attr({
method: method,
action: url
}).css({
display: 'none'
});
var form = $('<form>').attr({
method: method,
action: url
}).css({
display: 'none'
});

var addData = function(name, data) {
if ($.isArray(data)) {
for (var i = 0; i < data.length; i++) {
var value = data[i];
addData(name + '[]', value);
}
} else if (typeof data === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key)) {
addData(name + '[' + key + ']', data[key]);
}
}
} else if (data != null) {
form.append($('<input>').attr({
type: 'hidden',
name: String(name),
value: String(data)
}));
}
};

var addData = function(name, data) {
if ($.isArray(data)) {
for (var i = 0; i < data.length; i++) {
var value = data[i];
addData(name + '[]', value);
}
} else if (typeof data === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key)) {
addData(name + '[' + key + ']', data[key]);
addData(key, data[key]);
}
}
} else if (data != null) {
form.append($('<input>').attr({
type: 'hidden',
name: String(name),
value: String(data)
}));
}
};

for (var key in data) {
if (data.hasOwnProperty(key)) {
addData(key, data[key]);
return form.appendTo('body');
}
}

return form.appendTo('body');
}
}); });
});
});
});

0 comments on commit 46d4562

Please sign in to comment.