skrach Posted October 7, 2010 Report Share Posted October 7, 2010 (edited) Sveiki! Man radās viena problēma. Nekādigi nesanāk uzlikt class="current". Vienmēr taisīju un viss sanāca, bet tagad tam menu izmantoju javascipt un nevaru likt visu menu iekš PHP. Iekš <li> ir id="selected pirmajai lapai, tas ir priekš Javascript. Te ir HTML kods kurš atrodas header.php: <ul id="nav"> <li id="selected"><a href="index.php?page=home" class="<?php (($page == 'home') ? 'current' : '')?>">Sākums</a></li> <li><a href="index.php?page=services">Pakalpojumi</a></li> <li><a href="/" >Noderīgi padomi</a></li> <li><a href="index.php?page=gallery" >Galerija</a></li> <li><a href="/" >Cenas</a></li> <li><a href="index.php?page=contact" >Kontakti</a></li> </ul> Kods kurš atrodas iekš index.php: <?php require_once('header.php'); $page = (isset($_GET['page'])) ? $_GET['page'] : ''; switch($page) { case 'home': include "home.php"; break; case 'services': include "services.php"; break; case 'gallery': include "gallery.php"; break; case 'contact': include "contact.php"; break; default: include "home.php"; break; } require_once('footer.php'); ?> CSS kods: #nav { position: relative; background: #292929; top: 50px; left: 80px; } #nav li { float: left; list-style: none; border-right: 1px solid #111; border-left: 1px solid #111; } #nav li a { color: #e3e3e3; position: relative; z-index: 2; float: left; font-size: 12px; font-family: helvetica, arial, sans-serif; text-decoration: none; padding: 10px 15px; } #nav li a.current{ color: #7e292e; } Te ir tas Javascipts kods: (function($) { $.fn.spasticNav = function(options) { options = $.extend({ overlap : 10, speed : 500, reset : 1500, color : '#61b10a', easing : 'easeOutExpo' }, options); return this.each(function() { var nav = $(this), currentPageItem = $('#selected', nav), blob, reset; $('<li id="blob"></li>').css({ width : currentPageItem.outerWidth(), height : currentPageItem.outerHeight() + options.overlap, left : currentPageItem.position().left, top : currentPageItem.position().top - options.overlap / 2, backgroundColor : options.color }).appendTo(this); blob = $('#blob', nav); $('li:not(#blob)', nav).hover(function() { // mouse over clearTimeout(reset); blob.animate( { left : $(this).position().left, width : $(this).width() }, { duration : options.speed, easing : options.easing, queue : false } ); }, function() { // mouse out reset = setTimeout(function() { blob.animate({ width : currentPageItem.outerWidth(), left : currentPageItem.position().left }, options.speed) }, options.reset); }); }); // end each }; })(jQuery); Edited October 7, 2010 by skrach Quote Link to comment Share on other sites More sharing options...
nemakuphp Posted October 7, 2010 Report Share Posted October 7, 2010 (edited) Samaini require_once('header.php'); un $page = (isset($_GET['page'])) ? $_GET['page'] : ''; ar vietām, jo page mainīgo tu izveido vēlāk, nekā tas tiek izvadīts. Edited October 7, 2010 by nemakuphp Quote Link to comment Share on other sites More sharing options...
skrach Posted October 7, 2010 Author Report Share Posted October 7, 2010 Samaini require_once('header.php'); un $page = (isset($_GET['page'])) ? $_GET['page'] : ''; ar vietām, jo page mainīgo tu izveido vēlāk, nekā tas tiek izvadīts. Samainīju, bet tas tā pat nepalīdz. Quote Link to comment Share on other sites More sharing options...
Леший Posted October 7, 2010 Report Share Posted October 7, 2010 $page = (isset($_GET['page'])) ? $_GET['page'] : 'home'; Quote Link to comment Share on other sites More sharing options...
skrach Posted October 7, 2010 Author Report Share Posted October 7, 2010 $page = (isset($_GET['page'])) ? $_GET['page'] : 'home'; Nepalidz Quote Link to comment Share on other sites More sharing options...
foxsk8 Posted October 8, 2010 Report Share Posted October 8, 2010 Pamaini risinājumu, izskatās, nedaudz šķībs. Pameklē, šeit pat ir bijuši daudz un dažādi risinājumi priekš aktīviem menu. Quote Link to comment Share on other sites More sharing options...
Леший Posted October 8, 2010 Report Share Posted October 8, 2010 (edited) Ieraksti iekš header.php sākumā var_dump($page); Iespējams, atšķirās php versija, un $_GET masīvs nemaz neeksistē. Un pārliecinies ar View Source, ka tiešam nav uzlikta tā klase. Iespējams, ka klase ir, bet problēma ir ar JS. Edited October 8, 2010 by Леший Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.