Skip to content

Instantly share code, notes, and snippets.

@tarlepp
Created July 23, 2013 05:57
Show Gist options
  • Select an option

  • Save tarlepp/6060164 to your computer and use it in GitHub Desktop.

Select an option

Save tarlepp/6060164 to your computer and use it in GitHub Desktop.
body.on('taskAdd', function(event, story) {
jQuery.get('/Task/add', {projectId: story.projectId(), storyId: story.id()}, function(content) {
var title = "Add new task to story '" + ko.toJS(story.title()) + "'";
var buttons = [
{
label: "Save",
class: "btn-primary pull-right",
callback: function () {
var form = jQuery('#formTaskNew');
var formItems = form.serializeJSON();
// Validate current form items and try to create new task
if (validateForm(formItems)) {
jQuery.ajax({
type: 'POST',
url: "/task/",
data: formItems,
dataType: 'json'
})
.done(function(/** models.rest.task */task) {
makeMessage("Task created successfully.", "success", {});
// Add new task to current story first phase tasks
story.phases()[0].tasks.push(new Task(task));
modal.modal('hide');
})
.fail(function(jqXhr, textStatus, error) {
handleAjaxError(jqXhr, textStatus, error);
});
}
return false;
}
}
];
// Open bootbox modal
var modal = openBootboxDialog(title, content, buttons);
// Make form init when dialog is opened.
modal.on('shown', function() {
initTaskForm(modal, false);
});
})
.fail(function(jqXhr, textStatus, error) {
handleAjaxError(jqXhr, textStatus, error);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment