Fix paginator attributes cannot be modified bug
We can only use SetPaginator to create a pagination. After that, we always need to modify something, like the totalNum, perPageNum. These change should be seen in the view. So we should give the view a pointer than a object.
Showing
1 changed file
with
1 additions
and
1 deletions
| ... | @@ -21,6 +21,6 @@ import ( | ... | @@ -21,6 +21,6 @@ import ( |
| 21 | // Instantiates a Paginator and assigns it to context.Input.Data["paginator"]. | 21 | // Instantiates a Paginator and assigns it to context.Input.Data["paginator"]. |
| 22 | func SetPaginator(context *context.Context, per int, nums int64) (paginator *Paginator) { | 22 | func SetPaginator(context *context.Context, per int, nums int64) (paginator *Paginator) { |
| 23 | paginator = NewPaginator(context.Request, per, nums) | 23 | paginator = NewPaginator(context.Request, per, nums) |
| 24 | context.Input.Data["paginator"] = paginator | 24 | context.Input.Data["paginator"] = &paginator |
| 25 | return | 25 | return |
| 26 | } | 26 | } | ... | ... |
-
Please register or sign in to post a comment