updatepanel和JQuery的问题 [英] Problem with updatepanel and JQuery

查看:62
本文介绍了updatepanel和JQuery的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用jquery功能和更新面板在我的网站上显示新闻文章。

初始页面加载我正在加载10个项目,当向下滚动到页面结束时,我每次都要加载10个项目。

这样工作正常直到我使用带有不同div的标签部分。 />
当我有一个div时,一切都很顺利。

但是,当我使用多个div标签作为标签部分时,我遇到了问题。



代码:



 <   script     type   =  text / javascript >  

$(window).scroll(function(){
if($(document).height()< = $(window).scrollTop() + < span class =code-attribute> $(window).height()) {

< span class =code-attribute> var newscount = document.getElementById(' <% = hidNewsCount.ClientID% > ');
newscount.value = parseInt(newscount.value)+ 2;
document.getElementById('<% = btnLoadMoreNews.ClientID %> ')。点击();
}
});

< / script >





 <   asp:UpdatePanel     ID  < span class =code-keyword> =  udpNewsItems    runat   =  server    RenderMode   = 内联    ChildrenAsTriggers   =  true  

UpdateMode = 条件 >
< ContentTemplate >
< div id = < span class =code-keyword> tabbedcontent class = tabbing >
< ul class = tabbing-tabs >
< li id = lit1 >
< a id = aTab1 href = #Tab1 > < asp:Literal ID = litTab1 runat = 服务器 > < / asp:Literal > < / a >
< / li >
< li id = lit2 >
< a id = aTab2 href = #Tab2 > < asp:Literal ID = litTab2 runat = server > < / asp:Literal > < / a >
< / li >
< li id = lit3 >
< ; a id < span class =code-keyword> = aTab3 href = #Tab3 > < asp:Literal ID = litTab3 runat = 服务器 > < / asp:Literal > < / a >
< / li >
< span class =code-keyword>< li id = lit4 >
< a id = aTab4 href = #Tab4 > < asp:Literal ID = litTab4 runat = 服务器 > < / asp:文字 > < / a >
< / li >
< / ul >
< div class = tabbing-tabbed >
< h2 id = Tab1 >
< asp: Literal ID = litTitle runat = server > < / asp:Literal > < / h2 >
< div class = wysiwyg >
< asp: HiddenField ID = hidNewsCount runat = server / >
< div class = newsListing >
//用文字绑定新闻
< / div >
< asp:Literal ID = litNewsListing runat = 服务器 > < / asp:Literal >
< span class =code-keyword>< / div >
&l t; / div >
< div class = tabbing-tabbed >
< h2 id = Tab2 >
< asp:Literal ID = litTitle_LastYr runat = server > < / asp:Literal > < / h2 >
< div class = wysiwyg >
< div class = newsListing >
//用文字绑定新闻
< / div >
< asp:Literal < span class =code-attribute> ID = litNewsListing_LastYr runat = 服务器 > < / asp:Literal >
< / div >
< / div >
< div class = tabbing-tabbed >
< h2 id = Tab3 >
< asp:Literal ID = litTitle_TwoYrs runat = server > < / asp:Literal > < / h2 >
< div class = wysiwyg >
< div class = newsListing >
//用文字绑定新闻
< / div >
< asp:Literal ID = litNewsListing_TwoYrs runat = server > < < span class =code-leadattribute> / asp:Literal
>
< / div >
< ; <跨度class =code-leadattribute> / div >
< div class = tabbing-tabbed >
< h2 id = Tab4 >
< asp:Literal ID = litTitle_Old runat = server > < / asp:Literal > < / h2 >
< div class = wysiwyg >
< div class = newsListing >
//用文字绑定新闻
< / div >
< asp:Literal ID = litNewsListing_Old runat = server > < < span class =code-leadattribute> / asp:Literal >
< / div >
< ; / div >
< / div >
< / ContentTemplate >
< < span class =code-leadattribute>触发器 >
< asp:AsyncPostBackTrigger ControlID = btnLoadMoreNews EventName = 点击 / >
< / Triggers >
< / asp:UpdatePanel >
< asp:Button ID = < span class =code-keyword> btnLoadMoreNews runat = server 样式 = display:none OnClick = btnLoadMoreNews_Click / >









问题是,如果我在第三个标签页并到达页面的终点,同时滚动它会加载更多项目,但会自动显示第一个标签内容,而且我可以切换到任何其他标签。



请帮帮我。



非常感谢!!

解决方案

(窗口).scroll(function(){
if(


(document).height()< =


(窗口).scrollTop() +

Hi,

I'm using a jquery function and an updatepanel to show news articles in my website.
In the Initial page load I'm loading 10 items and when scrolled down to the page end I'm loading 10 more items every time.
This is working fine Until I used a tabbed section with different divs.
When I have one div everything goes good.
But, when I used multiple div tags as a tabbed section I have the problem.

Code:

<script type="text/javascript">

    $(window).scroll(function() {
        if ($(document).height() <= $(window).scrollTop() + $(window).height()) {

            var newscount = document.getElementById('<%=hidNewsCount.ClientID%>');
            newscount.value = parseInt(newscount.value) + 2;
            document.getElementById('<%=btnLoadMoreNews.ClientID%>').click();
        }
    });

</script>



<asp:UpdatePanel ID="udpNewsItems" runat="server" RenderMode="Inline" ChildrenAsTriggers="true"

    UpdateMode="Conditional">
    <ContentTemplate>
        <div id="tabbedcontent" class="tabbing">
            <ul class="tabbing-tabs">
                <li id="lit1">
                    <a id="aTab1" href="#Tab1"><asp:Literal ID="litTab1" runat="server"></asp:Literal></a>
                </li>
                <li id="lit2">
                    <a id="aTab2" href="#Tab2"><asp:Literal ID="litTab2" runat="server"></asp:Literal></a>
                </li>
                <li id="lit3">
                    <a id="aTab3" href="#Tab3"><asp:Literal ID="litTab3" runat="server"></asp:Literal></a>
                </li>
                <li id="lit4">
                    <a id="aTab4" href="#Tab4"><asp:Literal ID="litTab4" runat="server"></asp:Literal></a>
                </li>
            </ul>
            <div class="tabbing-tabbed">
                <h2 id="Tab1">
                    <asp:Literal ID="litTitle" runat="server"></asp:Literal></h2>
                <div class="wysiwyg">
                    <asp:HiddenField ID="hidNewsCount" runat="server" />
                    <div class="newsListing">
                      //Binding news with literals
                    </div>
                    <asp:Literal ID="litNewsListing" runat="server"></asp:Literal>
                </div>
            </div>
            <div class="tabbing-tabbed">
                <h2 id="Tab2">
                    <asp:Literal ID="litTitle_LastYr" runat="server"></asp:Literal></h2>
                <div class="wysiwyg">
                    <div class="newsListing">
                      //Binding news with literals
                    </div>
                    <asp:Literal ID="litNewsListing_LastYr" runat="server"></asp:Literal>
                </div>
            </div>
            <div class="tabbing-tabbed">
                <h2 id="Tab3">
                    <asp:Literal ID="litTitle_TwoYrs" runat="server"></asp:Literal></h2>
                <div class="wysiwyg">
                   <div class="newsListing">
                      //Binding news with literals
                    </div>
                    <asp:Literal ID="litNewsListing_TwoYrs" runat="server"></asp:Literal>
                </div>
            </div>
            <div class="tabbing-tabbed">
                <h2 id="Tab4">
                    <asp:Literal ID="litTitle_Old" runat="server"></asp:Literal></h2>
                <div class="wysiwyg">
                    <div class="newsListing">
                      //Binding news with literals
                    </div>
                    <asp:Literal ID="litNewsListing_Old" runat="server"></asp:Literal>
                </div>
            </div>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnLoadMoreNews" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
<asp:Button ID="btnLoadMoreNews" runat="server" Style="display: none" OnClick="btnLoadMoreNews_Click" />





The problem is, If I'm in a 3rd tab and reached the end point of the page while scrolling it loads more items, but shows the first tab content automatically and more over I'm notable to switch to any other tab.

Please help me.

Thanks alot!!

解决方案

(window).scroll(function() { if (


(document).height() <=


(window).scrollTop() +


这篇关于updatepanel和JQuery的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆