Creating another task stay in the popover
This commit is contained in:
@@ -15,7 +15,8 @@ Popover.prototype.open = function(link) {
|
||||
$.get(link, function(content) {
|
||||
$("body").append('<div id="popover-container"><div id="popover-content">' + content + '</div></div>');
|
||||
self.router.dispatch();
|
||||
self.app.listen();
|
||||
self.app.refresh();
|
||||
self.afterOpen();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -48,3 +49,29 @@ Popover.prototype.listen = function() {
|
||||
$(document).on("click", "#popover-container", this.close.bind(this));
|
||||
$(document).on("click", "#popover-content", function(e) { e.stopPropagation(); });
|
||||
};
|
||||
|
||||
Popover.prototype.afterOpen = function() {
|
||||
var self = this;
|
||||
var taskForm = $("#task-form");
|
||||
|
||||
if (taskForm) {
|
||||
taskForm.on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: taskForm.attr("action"),
|
||||
data: taskForm.serialize(),
|
||||
success: function(data, textStatus, request) {
|
||||
if (request.getResponseHeader("X-Ajax-Redirect")) {
|
||||
window.location = request.getResponseHeader("X-Ajax-Redirect");
|
||||
}
|
||||
else {
|
||||
$("#popover-content").html(data);
|
||||
self.afterOpen();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user