Для использования html в ui autocomplete добавить:
.data("ui-autocomplete")._renderItem=function(ul,item){
return $("<li></li>").data("item.autocomplete",item).append(item.label).appendTo(ul);
};
Полный текст:
$("#search").autocomplete({
source:"/ajax_search.php",
minLength:3,
select:function(event,ui){
$(this).val(ui.item.value.replace(/(<([^>]+)>)/ig,""));
$(this).parent('form').submit();
}
}).data("ui-autocomplete")._renderItem=function(ul,item){
return $("<li></li>").data("item.autocomplete",item).append(item.label).appendTo(ul);
};
или так, чтобы избавиться от тегов совсем:
$("#search").autocomplete({
source:"/ajax_search.php",
minLength:3,
select:function(event,ui){
event.preventDefault();
$(this).val(ui.item.value.replace(/(<([^>]+)>)/ig,""));
$(this).parent('form').submit();
}
}).data("ui-autocomplete")._renderItem=function(ul,item){
var bold='';
if(item.label.indexOf("<b>")!=-1){
bold=' style="font-weight:bold;"';
}
return $("<li"+bold+"></li>").data("item.autocomplete",item).append(item.label.replace(/(<([^>]+)>)/ig,"")).appendTo(ul);
};
Вместо:
$("#search").autocomplete({
source:"/ajax_search.php",
minLength:3,
select:function(event,ui){
$(this).val(ui.item.value);
$(this).parent('form').submit();
}
});
Для вертикальной прокрутки внутри блоков, созданных с использованием fullPage, использовать параметр:
Полный пример:
$(document).ready(function(){
$('#fullpage').fullpage({
anchors:['section-0','section-1','section-2'],
menu:'#navigation',
verticalCentered:false,
scrollOverflow:true,
afterLoad:function(anchorLink,index){
if(anchorLink=='section-0'){
$('#navigation').hide();
}
else{
$('#navigation').show();
}
},
});
});
<ul id="navigation">
<li data-menuanchor="section-1"><a href="#section-1">Section 1</a></li>
<li data-menuanchor="section-2"><a href="#section-2">Section 2</a></li>
</ul>
<div id="fullpage">
<div data-anchor="section-0" class="section section-0"></div>
<div data-anchor="section-1" class="section section-1"></div>
<div data-anchor="section-2" class="section section-2"></div>
</div>
.section-0{
background:red;
}
.section-1{
background:green;
}
.section-2{
background:blue;
}
#navigation{
position:fixed;
top:100px;
left:20px;
z-index:100;
}
#navigation li.active a{
color:red;
}
http://alvarotrigo.com/fullPage/
https://github.com/alvarotrigo/fullPage.js
Чтобы удалить из строки, содержащей html, элемент с его содержимым, в примере div
var str_html=$('.container').html();
str_html=str_html.replace(/<div[^>]*?>[\s\S]*?<\/div>/i,'');
Чтобы удалить элемент с определенным class, в примере class="classname"
str_html=str_html.replace(/<div.*(class="classname")[^>]*?>[\s\S]*?<\/div>/i,'');
В примере по адресу определяем район СПБ: Выборгский, Приморский и т.д.
Логика:
- Прямым геокодированием определяем координаты объекта.
- Обратным геокодированием с kind=district получаем район.
Подключаем api Яндекс:
<script src="//api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
Input:
<input type="text" name="address" id="address"/>
JS:
ymaps.ready(init);
function init(){
var suggestView=new ymaps.SuggestView('address');
suggestView.events.add('select',function(event){
var selected=event.get('item').value;
ymaps.geocode(selected,{
results:1
}).then(function(res){
return ymaps.geocode(res.geoObjects.get(0).geometry.getCoordinates(),{
kind:'district',
results:10
}).then(function(res){
var founded=res['metaData']['geocoder']['found'];
$('label.suggest .description').html("");
for(i=0;i<=founded-1;i++){
var info=res.geoObjects.get(i).properties.getAll();
console.log(info);
var name=info['name'];
if(name.search('район')!=-1){
name=name.replace(' район','');
console.log(name);
}
}
});
});
});
}