Well the plug-in that you are using is not meant for this purpose. This plug-in doesn't holds the logic to save the last visited link, that's the main reason why this plug-in is so damn small. So either you modify the plug-in or set the background of visited
link yourself through javacript.
All you need to is, get the current URL in javascript under document.ready. For eg. you get page name as abc.html
then you simply need to add the class "current" to get it selected. You can iterate and add class to it like
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); <== Get current, Just make sure you get correct value
alert(sPage);
$("ul#menu li").each(function(){ <== Iterate through the li Items
if ($(this).text() == sPage ) <== Find li with current URL
{ $(this).addClass("current"); } <== Add thew class to keep it selected
});
var loc = window.location.href;
var filename = loc.substring(loc.lastIndexOf('/')+1, loc.length); $('.lavalamp a, #dynamic-content a').each(function()
{
if ($(this).attr('href') == filename){
$(this).parent().addClass('current');
}
});
});
athar_techsa...
Member
554 Points
316 Posts
lavalamp losing its focus when redirected to another page?
Jun 26, 2011 06:45 AM|LINK
hi
I have used the lavalamp code from the following link http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/ Problem is when i click on <a> it is redirecting to its href page but it is not focussing on that particular page. My code is
<script type="text/javascript"> $(function() { $("#1, #2, #3").lavaLamp({ fx: "backout", speed: 700, click: function(event, menuItem) { return true; } }); }); </script><ul class="lavaLampBottomStyle" id="3"> <li><a href="../TBSFinPages/HomePage.aspx">Home</a></li> <li><a href="../TBSFinPages/FinHomePage.aspx">Financial Applications</a></li>princeG
Star
9612 Points
1602 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 26, 2011 06:57 AM|LINK
have you register all lavalamp file
http://stackoverflow.com/questions/5392064/why-does-nothing-happen-when-clicking-lavalamp-menu-in-jquery-asp-net
athar_techsa...
Member
554 Points
316 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 26, 2011 07:54 AM|LINK
hi
yes i have used all the js files but still not working.
hiren.sharma
Participant
1460 Points
311 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 26, 2011 12:23 PM|LINK
Well the plug-in that you are using is not meant for this purpose. This plug-in doesn't holds the logic to save the last visited link, that's the main reason why this plug-in is so damn small. So either you modify the plug-in or set the background of visited link yourself through javacript.
All you need to is, get the current URL in javascript under document.ready. For eg. you get page name as abc.html
then you simply need to add the class "current" to get it selected. You can iterate and add class to it like
$(function() {$(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 });
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); <== Get current, Just make sure you get correct value
alert(sPage);
$("ul#menu li").each(function(){ <== Iterate through the li Items
if ($(this).text() == sPage ) <== Find li with current URL
{ $(this).addClass("current"); } <== Add thew class to keep it selected
});
});
I have not tested it but it should work.
Try out My Blog | Visit My Website
asteranup
All-Star
30184 Points
4906 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 27, 2011 11:19 AM|LINK
Hi,
You can set the particular item as current selection by adding class current. Check the following articles-
http://stackoverflow.com/questions/3314116/jquery-lavalamp-selecting-focus-highlighting-item-within-lavalamp-when-hyperlink
http://stackoverflow.com/questions/2001624/jquery-lavalamp-focus
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
athar_techsa...
Member
554 Points
316 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 27, 2011 01:01 PM|LINK
hi
No use, according to ur links i changed my jQuery code to
$(function() { var loc = window.location.href; var filename = loc.substring(loc.lastIndexOf('/')+1, loc.length); $('.lavalamp a, #dynamic-content a').each(function() { if ($(this).attr('href') == filename){ $(this).parent().addClass('current'); } }); $(".lavalamp").lavaLamp({ fx: "backout", speed: 700 }) });hiren.sharma
Participant
1460 Points
311 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 27, 2011 06:00 PM|LINK
TRY THIS IF IT WORKS
$(function() {$(".lavalamp").lavaLamp({ fx: "backout", speed: 700 });$('.lavalamp a').removeClass('current');var loc = window.location.href; var filename = loc.substring(loc.lastIndexOf('/')+1, loc.length);$('.lavalamp a, #dynamic-content a').each(function() { if ($(this).attr('href') == filename){ $(this).parent().addClass('current'); } }); });
Try out My Blog | Visit My Website
asteranup
All-Star
30184 Points
4906 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 28, 2011 04:12 AM|LINK
Hi,
Do you have master page and lavalamp in masterpage?
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
athar_techsa...
Member
554 Points
316 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 28, 2011 07:43 AM|LINK
hi
Yes, i have lavalamp in masterpage.
asteranup
All-Star
30184 Points
4906 Posts
Re: lavalamp losing its focus when redirected to another page?
Jun 28, 2011 08:00 AM|LINK
Then,
This code should work.
$(function() { var loc = window.location.href; var filename = loc.substring(loc.lastIndexOf('/')+1, loc.length); $('.lavalamp a, #dynamic-content a').each(function(){ if ($(this).attr('href').indexOf(filename)>-1){ $(this).parent().addClass('current'); } }); $(".lavalamp").lavaLamp({ fx: "backout", speed: 700 }) });Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog