Last active
August 29, 2015 13:56
-
-
Save chrisamoore/9148813 to your computer and use it in GitHub Desktop.
Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="POST" action="http://frontline.dev/appointments/4" accept-charset="UTF-8"> | |
<input name="_method" type="hidden" value="PATCH"> | |
<input name="_token" type="hidden" value="PROPCMA5b4UC4SNexoexu2ANst1a1OLo7bjJTYzk"> | |
<input name="appointment_time" type="hidden" value="2014-02-20 13:00:00"> | |
<input name="status" type="hidden" value="ARRIVED"> | |
<div class="btn-group actions"> | |
<a class="status-btn btn " data-action="confirm">Confirmed</a> | |
<a class="status-btn btn btn-info " data-action="arrived">Arrived</a> | |
<a class="status-btn btn " data-action="complete">Completed</a> | |
<a class="status-btn btn " data-action="canceled">Cancel / refund</a> | |
<a class="status-btn btn " data-action="canceled">reschedule /schedule</a> | |
</div> | |
<input class="btn btn-info" type="submit" value="Update"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj; | |
$('form > input').each(function(k,v){ | |
if(typeof(obj) == 'undefined'){ | |
obj = {}; | |
} | |
obj[v.name] = v.value; | |
}); | |
$('.status-btn').on('click', function(){ | |
obj.status = $(this).data('action'); | |
console.log(update()); | |
}); | |
function update(){ | |
return $.ajax({ | |
url: $('form').attr('action'), | |
type: obj._method, | |
data: obj, | |
success: function (data) { | |
return data | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment