回答編集履歴
1
sample
test
CHANGED
@@ -3,3 +3,91 @@
|
|
3
3
|
tableリストを更新する処理後にページネーションのトリガーを発動させればいいでしょう。
|
4
4
|
|
5
5
|
非同期処理の同期なので$.whenやpromiseでやることになると思います
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
# 非同期処理のサンプル
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
- test1はfunc1、func2の順で指定したが戻りはfunc2→func1
|
14
|
+
|
15
|
+
- test2は$.whenで調整しているがfunc1が同期処理の順列処理に対応していないのでNG
|
16
|
+
|
17
|
+
- test3のようにするとfunc3、func2で実行すると、func3→func2の順で返ります
|
18
|
+
|
19
|
+
```javascript
|
20
|
+
|
21
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
22
|
+
|
23
|
+
<script>
|
24
|
+
|
25
|
+
$(function(){
|
26
|
+
|
27
|
+
$('input[type=button][value=test1]').on('click',function(){
|
28
|
+
|
29
|
+
func1();
|
30
|
+
|
31
|
+
func2();
|
32
|
+
|
33
|
+
});
|
34
|
+
|
35
|
+
$('input[type=button][value=test2]').on('click',function(){
|
36
|
+
|
37
|
+
$.when(func1()).done(function(){
|
38
|
+
|
39
|
+
func2();
|
40
|
+
|
41
|
+
});
|
42
|
+
|
43
|
+
});
|
44
|
+
|
45
|
+
$('input[type=button][value=test3]').on('click',function(){
|
46
|
+
|
47
|
+
$.when(func3()).done(function(){
|
48
|
+
|
49
|
+
func2();
|
50
|
+
|
51
|
+
});
|
52
|
+
|
53
|
+
});
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
function func1(){
|
58
|
+
|
59
|
+
setTimeout(function(){alert('func1');},3000);
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
function func2(){
|
64
|
+
|
65
|
+
setTimeout(function(){alert('func2');},1000);
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
function func3(){
|
70
|
+
|
71
|
+
var d = $.Deferred();
|
72
|
+
|
73
|
+
setTimeout(function(){d.resolve();alert('func3');},3000);
|
74
|
+
|
75
|
+
return d.promise();
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
</script>
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<input type="button" value="test1">
|
84
|
+
|
85
|
+
<input type="button" value="test2">
|
86
|
+
|
87
|
+
<input type="button" value="test3">
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
```
|