在web2py中没有onclick函数加载?

时间:2014-10-31 06:04:42

标签: jquery ajax web2py

我在索引页面中有一个链接

{if not auth.user:}}
    <li> <a href="#" id="pop" onclick="$('#overlay_form').load('/tskasiav3/default/user1');">Login</a></li>
    {{pass}}

并在用户页面中使用相同的链接。 onclick活动在用户页面中工作,但它在索引页面中不起作用。关于它为什么不起作用的任何帮助?

<link rel="stylesheet" type="text/css" href="{{=URL('static','css/tskasia.css')}}" />

<doctype html>

<head>
    <link rel="stylesheet" type="text/css" href="{{=URL('static','css/tskasia.css')}}" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
//open popup
        $("#pop").click(function(){
            $("#overlay_form").fadeIn(1000);
            positionPopup();
        });

//close popup
        $("#close").click(function(){
            $("#overlay_form").fadeOut(500);
        });
    });

    //position the popup at the center of the page
    function positionPopup(){
        if(!$("#overlay_form").is(':visible')){
            return;
        }
        $("#overlay_form").css({
            left: ($(window).width() - $('#overlay_form').width()) / 2,
            top: ($(window).width() - $('#overlay_form').width()) / 7,
            position:'absolute'
        });
    }

    //maintain the popup at center of the page when browser resized
    $(window).bind('resize',positionPopup);

</script>
    <style>
        #overlay_form{
            position: absolute;
            border: 5px solid limegreen;
            padding: 10px;
            background: white;

        }
        #pop{
            display: block;

            width: 80px;
            text-align: center;
            padding: 6px;
            border-radius: 5px;
            text-decoration: none;
            margin: 0 auto;
        }

}
    </style>





<body class="home">

<div id="container">
<header>

    <img src="{{=URL('static','images/header.png')}}" id="header" />

</header>

<nav>

<ul class="navigation">
   <li><a class="home" href="index.html">Home</a></li>
    <li><a class="about" href="about.html">About</a></li>
    <li><a class="product" href="products.html">Products</a></li>
    <li><a class="contact" href="contact.html">Contact</a></li>
    <li><a class="bookings" href="bookings.html">Bookings</a></li>
     <li><a class ="User" href="user1/profile">{{if auth.user:}}Account{{pass}}</a></li>

     {{if not auth.user:}}
    <li> <a href="#" id="pop" onclick="$('#overlay_form').load('/tskasiav3/default/user1');">Login</a></li>
    {{pass}}
    {{if auth.user:}}
    <li><a class ="Logout" href="user1/logout" id="Logout">Logout</a></li>
    {{pass}}

</ul>

    </nav>

<br />
<div id="overlay_form" style="display:none">
    <h2>{{=T( request.args(0).replace('_',' ').capitalize() )}}</h2>
<div id="web2py_user_form">

</div>


    </div>


    {{
if request.args(0)=='login':
    if not 'register' in auth.settings.actions_disabled:
        form.add_button(T('Register'),URL(args='register', vars={'_next': request.vars._next} if request.vars._next else None),_class='btn')
    pass
    if not 'request_reset_password' in auth.settings.actions_disabled:
        form.add_button(T('Lost Password'),URL(args='request_reset_password'),_class='btn')
    pass

pass



}}

    <script language="javascript">jQuery("#web2py_user_form input:visible:enabled:first").focus();
    {{if request.args(0)=='register':}}
    web2py_validate_entropy(jQuery('#auth_user_password'),100);
    {{elif request.args(0)=='change_password':}}
    web2py_validate_entropy(jQuery('#no_table_new_password'),100);
    {{pass}}
    </script>

    </div>
    </body>
    </head>
    </doctype>

这是在索引页面

<doctype html>
<head>
    <link rel="stylesheet" type="text/css" href="{{=URL('static','css/tskasia.css')}}" />
       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
       <script type="text/javascript">

    $(document).ready(function(){
        )} 



</script>
</head>


<body class="home">

<div id="container">
<header>

    <img src="{{=URL('static','images/header.png')}}" id="header" />


</header>

<nav>

<ul class="navigation">
    <li><a class="home" href="index.html">Home</a></li>
    <li><a class="about" href="about.html">About</a></li>
    <li><a class="product" href="products.html">Products</a></li>
    <li><a class="contact" href="contact.html">Contact</a></li>
    <li><a class="bookings" href="bookings.html">Bookings</a></li>
     <li><a class ="User" href="user1/profile">{{if auth.user:}}Account{{pass}}</a></li>

     {{if not auth.user:}}
     <li> <a href="#" id="pop" onclick="$('#overlay_form').load('/tskasiav3/default/user1');">Login</a></li>
    {{pass}}
    {{if auth.user:}}
    <li><a class ="Logout" href="user1/logout" id="Logout">Logout</a></li>
    {{pass}}


</ul>

</nav>

</doctype>

这一点是使用弹出式登录表单让用户输入他们的详细信息。

0 个答案:

没有答案
相关问题