fix form mulit post bug
Showing
3 changed files
with
7 additions
and
7 deletions
@@ -6,12 +6,12 @@ let r = new Router(); | @@ -6,12 +6,12 @@ let r = new Router(); | ||
6 | 6 | ||
7 | const index = { | 7 | const index = { |
8 | index: async(ctx, next) => { | 8 | index: async(ctx, next) => { |
9 | - console.log('index'); | ||
10 | - | ||
11 | - await ctx.render('index'); | 9 | + ctx.redirect('/projects'); |
12 | }, | 10 | }, |
13 | }; | 11 | }; |
14 | 12 | ||
15 | -r.get('/index', index.index); | ||
16 | - | 13 | +r.get('/', index.index); |
14 | +r.get('/index', (ctx, next) => { | ||
15 | + ctx.body = 'Todo'; | ||
16 | +}); | ||
17 | export default r; | 17 | export default r; |
@@ -159,7 +159,7 @@ | @@ -159,7 +159,7 @@ | ||
159 | 159 | ||
160 | <script> | 160 | <script> |
161 | $(function(){ | 161 | $(function(){ |
162 | - $(document.body).on('submit', 'form[data-pjax]', function(event) { | 162 | + $(document.body).off().on('submit', 'form[data-pjax]', function(event) { |
163 | event.preventDefault(); // stop default submit behavior | 163 | event.preventDefault(); // stop default submit behavior |
164 | $.pjax.submit(event, '#pjax-container', { | 164 | $.pjax.submit(event, '#pjax-container', { |
165 | type: 'POST' | 165 | type: 'POST' |
@@ -99,7 +99,7 @@ | @@ -99,7 +99,7 @@ | ||
99 | 99 | ||
100 | <script> | 100 | <script> |
101 | $(function(){ | 101 | $(function(){ |
102 | - $(document.body).on('submit', 'form[data-pjax]', function(event) { | 102 | + $(document.body).off().on('submit', 'form[data-pjax]', function(event) { |
103 | event.preventDefault(); // stop default submit behavior | 103 | event.preventDefault(); // stop default submit behavior |
104 | $.pjax.submit(event, '#pjax-container', { | 104 | $.pjax.submit(event, '#pjax-container', { |
105 | type: 'POST' | 105 | type: 'POST' |
-
Please register or login to post a comment