简体   繁体   English

Google App Engine中的无限滚动

[英]Infinite Scroll in google app engine

I am using Infinite-scroll Jquery for scroll down web pages. 我正在使用无限滚动Jquery向下滚动网页。 I am using bootstrap for designing. 我正在使用引导程序进行设计。 it works perfect for normal html code. 它非常适合普通的html代码。 But when i use bootstrap . 但是当我使用bootstrap时 It not showing any bootstrap component. 它没有显示任何引导程序组件。

When i put normal HTML code in temp.html file, it works perfectly. 当我将普通的HTML代码放在temp.html文件中时,它可以正常工作。 But when i am inserting bootstrap classes and its code to temp.html infinite scroll it is not working. 但是,当我将引导程序类及其代码插入temp.html无限滚动时,它不起作用。

Here is my Code for Handeller 这是我的处理程序代码

class Demo(webapp2.RequestHandler):
def get(self):
    conn = get_connection()
    data = conn.cursor()

    data.execute("""


    select * from table1

    """)
    alldata=data.fetchall()

    conn.commit()
    template=jinja_environment.get_template('demo.html')
    template_values={
                    'alldata':alldata

                     }
    self.response.out.write(template.render(template_values)) 

    conn.close()

Here is the demo.html 这是demo.html

<div id="content>
    <div class="accordion" id="accordion2">
      <div class="accordion-group">
        <div class="accordion-heading">
          <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
            {{alldata[0]}}
          </a>
        </div>
        <div id="collapseOne" class="accordion-body collapse in">
          <div class="accordion-inner">
            Anim pariatur cliche...
          </div>
        </div>
      </div>
      <div class="accordion-group">
        <div class="accordion-heading">
          <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
             {{alldata[0]}}
          </a>
        </div>
        <div id="collapseTwo" class="accordion-body collapse">
          <div class="accordion-inner">
            Anim pariatur cliche...
          </div>
        </div>
      </div>
    </div>
</div>
<a id="next" href="#">next page?</a>
<script>
$('#content').infinitescroll({
        navSelector     : "#next:last",
        nextSelector    : "a#next:last",
        itemSelector    : "#content p",
        debug           : true,
        dataType        : 'html',
        maxPage         : 200,
        path: function(index) { 
        return "/ScrollBarDemo/" + index

        }
    }, function(newElements, data, url){ 

    });
    </script>

Here is the Scroll Class 这是滚动类

class ScrollBarDemo(BaseHandler):
    def get(self,index):
       template=jinja_environment.get_template('temp.html')
       self.response.out.write(template.render() 

temp.html [WORKING] temp.html [工作中]

<div id="content">
    <p>





    <input type="text">


    </p>
</div>

temp.html [NOT WORKING] temp.html [不工作]

      <div class="accordion" id="accordion2">
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
        Collapsible Group Item #1
      </a>
    </div>
    <div id="collapseOne" class="accordion-body collapse in">
      <div class="accordion-inner">
        Anim pariatur cliche...
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
        Collapsible Group Item #2
      </a>
    </div>
    <div id="collapseTwo" class="accordion-body collapse">
      <div class="accordion-inner">
        Anim pariatur cliche...
      </div>
    </div>
  </div>
</div>

Try comparing your working and non-working files. 尝试比较您的工作文件和非工作文件。 Also try using the debugger in Chrome. 另外,请尝试在Chrome中使用调试器。

It's difficult to tell what's wrong. 很难说出问题所在。

For one thing, your excerpt from class ScrollBarDemo() is missing a closing parenthesis and semicolon. 一方面,您从ScrollBarDemo()类中摘录的内容缺少右括号和分号。 Also you don't have a #content element in your not working temp.html. 另外,在不工作的temp.html中没有#content元素。

In general, this is a debugging exercise. 通常,这是一个调试练习。 You should go through some basic debugging steps to determine what's wrong. 您应该通过一些基本的调试步骤来确定问题所在。 It'll be a better question if you can narrow down what's wrong and ask a more specific question. 如果您可以缩小问题范围并提出更具体的问题,这将是一个更好的问题。

Also, this problem doesn't have much to do with app engine or python. 另外,这个问题与应用引擎或python没有太大关系。 It seems likely to be something wrong in your javascript/html. 您的javascript / html中似乎有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM