main.html 向show.html 页面通过自定义事件传递参数
main.html
mui.each(data,function(i,n){
var livelist = document.getElementById("livelist");
var li = document.createElement("li");
var a = document.createElement("a");
var img = document.createElement("img");
var div = document.createElement("div");
var span= document.createElement("span");
var span = document.createElement("span");
a.setAttribute('href','show.html');
a.setAttribute('id',n.id);
//mui.alert(n.id);
img.setAttribute('class','mui-media-object');
img.setAttribute('src',n.livePic ? n.livePic : 'images/logo.png');
div.setAttribute('class','mui-media-body');
div.setAttribute('style','text-align: left; position:relative;');
span.setAttribute('style',' position:absolute; left:3px;');
span.innerText = n.name;
//span.innerText = n.name;
li.className = 'mui-table-view-cell mui-media mui-col-xs-6';
li.appendChild(a);
a.appendChild(img);
a.appendChild(div);
div.appendChild(span);
livelist.appendChild(li);
//open show.html
var liveid = n.id;
live = document.getElementById(liveid);
live.addEventListener('tap','a',function(e){
mui.fire(show,'liveID',{id:liveid});
mui.openWindow({
id:'show',
url:'show.html'
});
});
});
show.html
mui.plusReady(function() {
window.addEventListener('liveID',function(event){
var liveid = event.detail.id;
mui.alert(liveid);
});
});
能不能怎样写,如果不能的话该怎么修改
avst (作者)
谢谢,但是在show.html页面中的并没有接到参数,并且都没有进入到window.addEventListener('liveID',function(event)中,因为我mui.alert(1);都不会出东西,这是什么原因
2015-09-02 15:27