views:

78

answers:

5

i have a list of menus

<ul>
    <li><a href="#about" id="about">ՄԵՐ ՄԱՍԻՆ</a></li>
    <li><a href="#products" id="products" >ԱՐՏԱԴՐԱՆՔ</a></li>
    <li><a href="#farm" id="farm" >ՏՆՏԵՍՈՒԹՅՈՒՆ</a></li>
    <li><a href="#gallery" id="gallery" >ՆԿԱՐՆԵՐ</a></li>
    <li><a href="#contacts" id="contacts">ՀԵՏԱԴԱՐՁ ԿԱՊ</a></li>
</ul>

and i use address plugin to have back/forward along ajax, but i have a little bug, that can't fix.

when i click on menus, if the page has scrolling, it moove the page until the menu appear in the top of page, but i don't need it.

maybe there is a method, i can disable such behavior...

Thanks much

+1  A: 

try adding the following to your links:

onclick="return false;"

Since you are probably adding an event handler to this link for the click event. Just add the return false to the end of it rather than directly on the HTML tag.

spinon
it doesn;t work by so:( `addres` plugin start not working too
Syom
Ok I looked at the plugin sample page and I notice that they are not binding the click event but rather then change and externalChange event. Are you doing the same thing?http://www.asual.com/jquery/address/samples/tabs/#Changed to remove code since it looks like terrible.
spinon
+1  A: 

Create or modify the click() handlers for the links to use the preventDefault() method.

For example:

$("a").click 
(
    function (evt)
    {
        //YOUR CODE HERE

        evt.preventDefault(); 
        return false;  
    } 
);
Brock Adams
A: 

As andres descalzo says, it moove becouse they have the same id, then in href. So i just need to change the id of a tags

    <a href="#about" id="_about">ՄԵՐ ՄԱՍԻՆ</a>
    <a href="#products" id="_products"> ԱՐՏԱԴՐԱՆՔ</a>
   ....................................................

it solves the whole problem.

Thanks all of you for your attention, and ideas;)

Syom
+1  A: 

'href="#about"' refers to the element with the id 'about'. that is why the page is moved

<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
</head>
<body>

    <div id="datosResultado">
        1<br />
        2<br />
        3<br />
        4<br />
        5<br />
        6<br />
        7<br />
        8<br />
        9<br />
        10<br />
    </div>
    <ul id="yourMenu">
        <li><a href="#about" id="about">about</a></li>
        <li><a href="#products" id="products">products</a></li>
        <li><a href="#farm" id="farm">farm</a></li>
        <li><a href="#gallery" id="gallery">gallery</a></li>
        <li><a href="#contacts" id="contacts">contacts</a></li>
    </ul>

    <div id="you-click"></div>

</body>

<script type="text/javascript">

$(function(){

    $("#yourMenu>li>a").bind("click", function(ev){

        ev.stopPropagation();

        //...your code...

        $("#you-click").html($(this).html());

        return false;
    });
});

</script>
andres descalzo
Thanks for idea. I just need to set them other `ID` - s, then the `href` value. `<a href="#about" id="_about">`, it is all;)...
Syom
A: 

try doing this: $("a").click(function() { return false; });

Sudhir