mui.plusReady(function() {
var header = document.getElementById("header");
//封装标题栏
var titleElem = document.createElement('h1');
titleElem.className='mui-title';
titleElem.innerText='通知公告';
//封装搜索栏
var inputElem = document.createElement('input');
inputElem.type = "search";
inputElem.id = "search";
inputElem.className = '';
inputElem.placeholder = '请输入名称查询';
var searchElem = document.createElement('form');
searchElem.className = 'mui-input-row mui-search';
searchElem.appendChild(inputElem);
//预先加载标题
//header.appendChild(titleElem);
console.log(searchElem.innerHTML);
mui('.mui-bar').on('tap', '.mui-icon-search',function() {
var telem = header.querySelector('.mui-title');
if (telem) {
header.removeChild(telem);
header.appendChild(searchElem);
}else{
header.removeChild(searchElem);
header.appendChild(titleElem);
}
});
document.getElementById("search").addEventListener("keydown", function(e) {
if(13 == e.keyCode) { //点击了“搜索”
var title = document.getElementById("search").value;
if(isBlank(title)) {
mui.alert('请输入通知名称!');
return;
}
//pulldownRefresh();
document.activeElement.blur(); //隐藏软键盘
}
}, false);
});
1 个回复
exlce (作者)
form 上 加了 action="#" 之后,第一次还是一样, 再次点出搜索框,就不会了