Skip to content

Instantly share code, notes, and snippets.

@trandaison
Last active December 6, 2016 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trandaison/6f4a2f46b7d46950bd7b0dd67d579b86 to your computer and use it in GitHub Desktop.
Save trandaison/6f4a2f46b7d46950bd7b0dd67d579b86 to your computer and use it in GitHub Desktop.
Demo input
<button type="button" name="submit" class="btn-save btn-primary btn">Save</button>
<script>
$(document).ready(function() {
$('.btn-save').on('click', function() {
$.ajax({
type: 'POST',
url: '/workspaces/<%= params[:id] %>',
data: {
_method: "patch",
nodeDataArray: [
{"key":"G1", "isGroup":true, "pos":"0 0", "size":"200 200", "name":"A Group 1"},
{"key":"G2", "isGroup":true, "pos":"200 0", "size":"200 200", "name":"A Group 2"},
{"key":"Sec-1", "isGroup":true, "pos":"0 200", "size":"200 200", "name":"A Group 3"},
{"key":"Sec-2", "isGroup":true, "pos":"200 200", "size":"200 200", "name":"A Group 4"},
{"key":"b", "color":"#81D4FA", "size":"50 50", "pos":"50 50", "group":"G1", "name":"user 1", "type":"1", "user_id":"3"},
{"key":"g", "color":"#B2FF59", "size":"100 50", "pos":"250 50", "group":"G2", "name":"user 2", "type":"1", "user_id":"4"},
{"key":"g2", "color":"#B2FF59", "pos":"250 100", "group":"G12", "size":"50 50", "name":"user 3", "type":"1", "user_id":"5"},
{"key":"g3", "color":"#B2FF59", "pos":"300 100", "group":"G2", "size":"50 50", "name":"user 4", "type":"1", "user_id":"6"},
]
},
dataType: 'json',
success: function(data) {
console.log(data);
},
error: function(data) {
console.log(data);
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment