add show form sent via ajax request, opens sections with errors if not completed properly.

This commit is contained in:
Naomi 2011-02-10 15:00:55 -05:00
parent a32550d625
commit 2b5927bf33
6 changed files with 129 additions and 63 deletions

View file

@ -127,11 +127,41 @@ function setAddShowEvents() {
$("#add-show-submit")
.button()
.click(function(){
$("form").submit();
.click(function(event){
event.preventDefault();
var data = $("form").serializeArray();
var y;
$.post("/Schedule/add-show", {format: "json", data: data}, function(json){
if(json.form) {
$("#add-show-form")
.empty()
.append(json.form);
setAddShowEvents();
showErrorSections();
}
else {
scheduleRefetchEvents();
}
});
});
}
function showErrorSections() {
if($("#schedule-show-when .errors").length > 0) {
$("#schedule-show-when").show();
}
if($("#schedule-show-who .errors").length > 0) {
$("#schedule-show-who").show();
}
if($("#schedule-show-style .errors").length > 0) {
$("#schedule-show-style").show();
}
}
$(document).ready(function() {
setAddShowEvents();