30 марта 2016
Нет комментариев
$("#search").autocomplete({ source:"/ajax_search.php", minLength:4, select:function(event,ui){ $(this).val(ui.item.value); $(this).parent('form').submit(); } });
$("#search").autocomplete({ source:"/ajax_search.php", minLength:4, select:function(event,ui){ $(this).val(ui.item.value); $(this).parent('form').submit(); } });
В примере нужно в inline datepicker сделать активными только те даты, когда публиковались материалы, соответственно по клику на дату — фильтр.
Собираем все даты в массив:
$ann_dates=array(); $all_ann=get_from_base('date','announce','1','id'); foreach($all_ann as $item){ $ann_dates[]=date('Y-m-d',$item['date']); } $ann_dates=json_encode($ann_dates);
Добавляем beforeShowDay
:
$(document).ready(function(){ class_enabled='enabled'; class_disabled='disabled'; dates=<?=$ann_dates?>; $("#datepicker").datepicker({ inline:true, <?if($_GET['type']=='announce'&&isset($_GET['d'])&&isset($_GET['m'])&&isset($_GET['y'])){?> defaultDate:"<?=$_GET['d']?>.<?=$_GET['m']?>.<?=$_GET['y']?>", <?}?> beforeShowDay:function(d){ var date=$.datepicker.formatDate('yy-mm-dd',d); for(i=0,c=dates.length;i<c;i++){ if(date==dates[i]){ return[true,class_enabled]; } } return[false,class_disabled]; }, onSelect:function(dateText,inst){ $(this).css("background-color",""); window.location.href="/announce/?d="+inst.selectedDay+"&m="+(inst.selectedMonth+1)+"&y="+inst.selectedYear } }); });
Это упрощенный вариант на основе реализации для Modx:
https://habrahabr.ru/post/111155/
function spin_change(){ var count=$('#n').val(); var href=$('.detail_buy_button a').attr('href'); $('.detail_buy_button a').attr('href',href.replace(/&n=[^&]+/,'&n='+count)); }
$('#square').bind("change keyup input click",function(){ if(this.value.match(/[^0-9]/g)){ this.value=this.value.replace(/[^0-9]/g,''); } });
Обновлено:
Разрешать точку (для дробных чисел). При этом заменять запятую на точку при вводе.
$('.calc input').bind("change keyup input click",function(){ if(this.value.match(/,/)){ this.value=this.value.replace(/,/,'.'); } if(this.value.match(/[^0-9.]/g)){ this.value=this.value.replace(/[^0-9.]/g,''); } });
$(document).ready(function(){ $('#form_id').keydown(function(event){ if(event.keyCode==13){ event.preventDefault(); return false; } }); });
В примере из модального окна нужно выйти на страницу с тем же REQUEST_URI (ЧПУ), но на другом поддомене.
<a href="http://<?=$sd.$domain?>/" onclick="location.href='http://<?=$sd.$domain?>'+window.parent.location.pathname;parent.$.fancybox.close();return false;"><?=$city['name']?></a>
$('.carousel_left>.viewport').jcarousel({ animation:{duration:0} }).jcarouselAutoscroll({ interval:5000, target:'+=1', autostart:true }); $('.carousel_left>.viewport').on('jcarousel:animate',function(event,carousel){ $(carousel._element.context).find('li').hide().fadeIn(1000); });