Skip to content

Commit dae80e6

Browse files
committed
Merge pull request #101 from zhangxinxu/develop
fix page recreate and function recall bug
2 parents ca2300a + 28681fe commit dae80e6

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" : "mobilebone",
3-
"version" : "1.1.3",
3+
"version" : "2.4.3",
44
"main" : "src/mobilebone.js",
55
"license" : "MIT",
66
"dependencies" : {},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobilebone",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"description": "Bone main for mobile web APP with a sigle page mode.",
55
"main": "src/mobilebone.js",
66
"directories": {

src/mobilebone.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* @type string
4040
**/
41-
Mobilebone.VERSION = '2.4.2';
41+
Mobilebone.VERSION = '2.4.3';
4242

4343
/**
4444
* Whether catch attribute of href from element with tag 'a'
@@ -285,7 +285,7 @@
285285
}
286286

287287
// do transition
288-
if (pageOut) pageInto.classList.add(params_in.form);
288+
if (pageOut) pageInto.classList.add(params_in.form);
289289
// iOS bug
290290
// reflow for fixing issues #80, #86
291291
pageInto.offsetWidth = pageInto.offsetWidth;
@@ -298,7 +298,7 @@
298298

299299
// do callback when come in first time
300300
var onpagefirstinto = params_in.onpagefirstinto;
301-
if (!store[pageid]) {
301+
if (!store[pageid] && !store[hashid]) {
302302
if (typeof onpagefirstinto == "string" && params_in.root[onpagefirstinto]) {
303303
params_in.root[onpagefirstinto](pageInto, pageOut, options);
304304
} else if (typeof onpagefirstinto == "function") {
@@ -362,6 +362,10 @@
362362
// store page-id, just once
363363
if (!store[pageid]) {
364364
store[pageid] = pageInto;
365+
// when we back/prev, we need to get true
366+
if (hashid !== pageid) {
367+
store[hashid] = pageInto;
368+
}
365369
}
366370

367371
// do callback every time

test/ajax-html/index.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<li><a href="root-reload.php?id=2" data-reload="root">根地址不缓存2</a></li>
2828
</ul>
2929
<ul>
30-
<li><a href="b.html">连续加载测试-加载b页面</a></li>
30+
<li><a href="b.html" data-reload="root">连续加载测试-加载b页面</a></li>
31+
<li><a href="b.html?a=1" data-reload="true">连续加载测试-加载b页面</a></li>
3132
</ul>
3233
<ul>
3334
<li><a href="http://www.zhangxinxu.com/sp/char.html" target="_blank">外部地址测试,应该直接跳转</a></li>
@@ -38,6 +39,7 @@
3839
</div>
3940

4041
<script src="../../src/mobilebone.js"></script>
42+
<script src="../complex/js/zepto-docs.js"></script>
4143
<script>
4244
var optionsTest = function(elein, eleout, options) {
4345
// ajax过场回调options参数测试
@@ -60,7 +62,10 @@
6062
};
6163

6264
var page_b_first = function() {
63-
// console.log("first?");
65+
console.log("first?");
66+
};
67+
var page_root_first = function() {
68+
console.log("root?");
6469
};
6570
</script>
6671
</body>

test/ajax-html/root-reload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66

77
<body>
8-
<div class="page out" data-callback="root_reload">
8+
<div class="page out" data-callback="root_reload" data-onpagefirstinto="page_root_first">
99
<p>document.getElementById("idShow").innerHTML是:<strong id="idShow">&nbsp;</strong>,应该结果是<strong id="idShould"><?php echo $_GET['id']; ?></strong>.</p>
1010
<ul>
1111
<li><a href="#pageHome" data-rel="back">返回</a></li>

test/form-submit/search.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<li class="p5 bgf0 mt1 btc">搜索结果1</li>
1515
<li class="p5 bgf0 mt1 btc">搜索结果2</li>
1616
<li class="p5 bgf0 mt1 btc">搜索结果3</li>
17+
<li><a href="../ajax-html/c.html">C页面</a></li>
1718
<li><a href="#pageHome" data-rel="back">点此返回</a></li>
1819
</ul>
1920
</div>

0 commit comments

Comments
 (0)