使用JQuery查看不起作用

时间:2012-06-25 09:27:23

标签: php jquery codeigniter

我已经开发了一些脚本来检测用户何时向下滚动页面,它可以在简单的脚本上运行,如果我使用CodeIgniter,它现在不起作用。我已将库放入项目的根目录。视图中有一些代码:

更新:页面的完整代码

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; 
              charset=UTF-8" />
        <link href="/bootstrap/css/bootstrap.css" rel="stylesheet">
        <link href="/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
        <style type="text/css">
            body {
                padding-top: 60px;
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
        <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery.jeditable.js"></script>
        <script type="text/javascript" charset="utf-8"> 
        $(document).ready(function()
                {
            $(window).scroll(function()
                        {
                if  ($(window).scrollTop() == $(document).height() - $(window).height())
                                {
                                    alert('1');
                }
            }); 
        }); 
    </script>
    </head>
    <body>
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container-fluid">
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </a>
                    <a class="brand" href="#">Translation project</a>
                    <div class="btn-group pull-right">
                        <a class="btn btn-primary" href="<?=$fb_url;?>">
                            <i class="icon-user"></i>
                            <?=$user_title;?>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="#">Profile</a></li>
                            <li class="divider"></li>
                            <li><a href="#">Sign Out</a></li>
                        </ul>
                    </div>
                    <div class="nav-collapse">
                        <ul class="nav">
                            <li><a href="<?php echo $base_url.'view_testing' ?>">Home</a></li>
                            <li><a href="#about">About</a></li>
                            <li><a href="#contact">Contact</a></li>
                        </ul>
                    </div><!--/.nav-collapse -->
                </div>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span3">
                    <div class="well sidebar-nav">
                        <ul class="nav nav-list">
                            <li class="nav-header">Languages</li>
                            <?php
                                foreach ($languages as $language)
                                {
                                    $url=$base_url.'language_testing/'.$language['language_code'];
                                    if ($language['language_value']==$current_language['language_value'])
                                    {
                                        echo "<li class='active'><a href='{$url}'>".$language['language_value']." (".
                                            $language['translated']."/".$total_labels_number.")</a></li>";
                                    }
                                    else
                                    {
                                        echo "<li><a href='{$url}'>".$language['language_value']." (".
                                            $language['translated']."/".$total_labels_number.")</a></li>";
                                    }
                                }
                            ?>
                        </ul>
                    </div>
                </div><!--/span-->
                <div class="span9">
                    <div class="hero-unit-little">
                        <h2>
                            <?php
                                echo 'Translations for '.$current_language['language_value'].' ('.
                                    $current_language['translated'].'/'.$total_labels_number.')';
                            ?>
                        </h2>
                    </div>
                        <table>
                            <tbody>
                                <?php
                                    foreach ($records as $record) {
                                        echo "<tr style='border-bottom: 1px dotted silver;'>";
                                        echo "<td width='500'>" . strip_tags($record['language_value']) . "</td>";
                                        if ($record['approved_translation'])
                                        {
                                            echo "<td class ='output' id='".$record['index']."' style='vertical-align:middle' width='200'>" . "<b>".$record['approved_translation']['language_value'].
                                                "</b>"."</td>";
                                        }
                                        else
                                        {
                                            echo "<td class = 'output' id='".$record['index']."' style='vertical-align:middle' width='200'>" . "<b>Not translated</b>" . "</td>";   
                                        }                   
                                        echo '</tr>';
                                    }
                                ?>
                            </tbody>
                        </table>
                        <br/>                  
                </div>
            </div>
    </body>
</html>

但现在它不响应滚动。请告诉我为什么?

1 个答案:

答案 0 :(得分:0)

我会尝试在您的$(document).ready()

之前插入此内容
!window.jQuery && alert('jQuery NOT loaded!');

如果看到此对话框,则表示jQuery库无法加载(路径看起来不正确),因此您需要修复路径。 编辑:如果它位于网站根目录中,只需将正斜杠 - / - 添加到当前网址的开头。