Authored by 阿达

解决搜索bug fix

... ... @@ -102,6 +102,18 @@ function searchInput() {
searchResult();
}
function isLocalStorageSupported() {
var testKey = 'test',
storage = Window.prototype.localStorage;
try {
storage.setItem(testKey, 'testValue');
storage.removeItem(testKey);
return true;
} catch (error) {
return false;
}
}
//绑定提交前的存local操作
function bindWirteLocal($brandList, list) {
$brandList.on('click', 'p , li', function(e) {
... ... @@ -227,7 +239,10 @@ function searchResult() {
// 插入 dom,绑定事件
$('.search-result').html(html);
changeBackground();
bindWirteLocal($('.brand-list'), true);
if (isLocalStorageSupported){
bindWirteLocal($('.brand-list'), true);
}
}
loading.showLoadingMask();
... ...
... ... @@ -60,6 +60,18 @@ $('#search').on('touchend', function() {
return false;
});
function isLocalStorageSupported() {
var testKey = 'test',
storage = Window.prototype.localStorage;
try {
storage.setItem(testKey, 'testValue');
storage.removeItem(testKey);
return true;
} catch (error) {
return false;
}
}
//初始化历史搜索的内容
(function() {
var html = '',
... ... @@ -89,4 +101,8 @@ $('#search').on('touchend', function() {
}
}());
writeSearch.bindWirteLocal($form);
if (isLocalStorageSupported) {
writeSearch.bindWirteLocal($form);
}
... ...