Authored by 姜枫

fix form mulit post bug

... ... @@ -6,12 +6,12 @@ let r = new Router();
const index = {
index: async(ctx, next) => {
console.log('index');
await ctx.render('index');
ctx.redirect('/projects');
},
};
r.get('/index', index.index);
r.get('/', index.index);
r.get('/index', (ctx, next) => {
ctx.body = 'Todo';
});
export default r;
\ No newline at end of file
... ...
... ... @@ -159,7 +159,7 @@
<script>
$(function(){
$(document.body).on('submit', 'form[data-pjax]', function(event) {
$(document.body).off().on('submit', 'form[data-pjax]', function(event) {
event.preventDefault(); // stop default submit behavior
$.pjax.submit(event, '#pjax-container', {
type: 'POST'
... ...
... ... @@ -99,7 +99,7 @@
<script>
$(function(){
$(document.body).on('submit', 'form[data-pjax]', function(event) {
$(document.body).off().on('submit', 'form[data-pjax]', function(event) {
event.preventDefault(); // stop default submit behavior
$.pjax.submit(event, '#pjax-container', {
type: 'POST'
... ...