Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Kawfee and js, and a Guardfile to compile the script automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain Barnett committed Mar 7, 2012
1 parent c71d866 commit da1c3b2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'coffeescript', :input => "coffee", :output => 'public/js'
21 changes: 21 additions & 0 deletions coffee/jquery.related_table.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
jQuery ($) ->

$.ajaxSetup
data:
c: 3,
d: 4


$("#form1").submit ->
console.log( "ser: #{$(@).serialize()}")
$.ajax
url: "/"
data: $(@).serialize()
type: "POST"
success: (res, status, xhr) =>
console.log "res: #{res}"
error: (xhr,status, err) =>
console.log "failed with error: #{err}"
complete: (xhr, status) =>
console.log("finished with status: #{status}")
false # prevent form submission via html
31 changes: 31 additions & 0 deletions public/js/jquery.related_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(function() {

jQuery(function($) {
$.ajaxSetup({
data: {
c: 3,
d: 4
}
});
return $("#form1").submit(function() {
var _this = this;
console.log("ser: " + ($(this).serialize()));
$.ajax({
url: "/",
data: $(this).serialize(),
type: "POST",
success: function(res, status, xhr) {
return console.log("res: " + res);
},
error: function(xhr, status, err) {
return console.log("failed with error: " + err);
},
complete: function(xhr, status) {
return console.log("finished with status: " + status);
}
});
return false;
});
});

}).call(this);

0 comments on commit da1c3b2

Please sign in to comment.