lafer
lafer
  • 发布:2015-01-20 10:50
  • 更新:2015-01-20 15:02
  • 阅读:1228

文章列表点到详情不更新

分类:MUI

我现在有一个文章列表,第一次点进详情会取到正确数据,第二次点另一条的时候进去就不更新了,直接显示的第一次的隐藏的详情页面,我放了js代码也不执行

2015-01-20 10:50 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

贴一下你的详情页代码

lafer

lafer (作者)

<script type="text/javascript">  
            var ws = null, wo = null, page = 1;  

            window.onload = function(){  

                mui.init();  

                mui.plusReady(function(){  

                    ws = plus.webview.currentWebview();  
                    wo = ws.opener();  
                    page = ws.dataId;  

                    mui('body').on('tap', 'a', function(e) {  
                        var id = this.getAttribute('href');  
                        var type = this.getAttribute('open-type');  
                        if (id) {  
                            if(~id.indexOf('.html')) {  
                                mui.openWindow({  
                                    id: id,  
                                    url: this.href,  
                                    preload: true  
                                });  
                            } else {  
                                if (typeof plus !== 'undefined') {  
                                    plus.runtime.openURL(id);  
                                }  
                            }  
                        }  
                    });  

                    plus.nativeUI.showWaiting();  
                    ajax();  

                    mui.back = function(){  
                        mui.openWindow({  
                            id: 'glhd.html',  
                            url: 'glhd.html',  
                            preload: true  
                        });  
                        setTimeout(function(){  
                            plus.webview.currentWebview().close();  
                        },300);  
                    }  

                });  

            }  

            var ajax = function(){  
                var url = plus.storage.getItem('ip') "wetlandpark/page/News_appDetail.action";  
                var type = "get";  
                var dataType = "json";  
                var data = {  
                    id:ws.dataId  
                }  

                mui.getJSON(url, data, function(d){  

                    plus.nativeUI.closeWaiting();  

                    if(d.result == '00'){  
                        document.querySelector('#newcon').innerHTML = '<h2 class="ne-tit">' d.title '</h2><span class="ne-con-tip">(时间:' d.time '  点击:' d.clicknum ')</span><div class="ne-con">' d.content '</div>'  
                    }else{  
                        alert("数据获取失败!");  
                    }  
                });  
            }  

        </script>
DCloud_UNI_FXY

DCloud_UNI_FXY

你这个详情页是预加载模式?不要把取数据放在onload里边,预加载的话只会onload一次。
你应该在pagebeforeshow事件里重新加载新的数据

lafer

lafer (作者)

好的 我试一下

DCloud_UNI_CHB

DCloud_UNI_CHB

你也可以在每次打开详情页面时,通过自定义事件触发详情页面获取对应的详情;

参考mui自定义事件,其中有列表到详情的示例;

lafer

lafer (作者)

好的 谢谢帮助

该问题目前已经被锁定, 无法添加新回复