jQuery动态更新字段滚动页面 [英] jQuery Dynamically Updating Fields Scrolls Page

查看:161
本文介绍了jQuery动态更新字段滚动页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户填写的表单,单击保存并将其下移到表中。从那里他们可以编辑一行或删除它。

I have a form a user fills out, clicks "save" and it gets moved down into a table. From there they can edit a row or delete it.

但是,每次从表中添加或删除某些内容,或者从表中重新填充字段进入表单(并从表中删除,直到再次保存)页面跳回到顶部。

However, every time something is added or removed from the table, or the fields are re-populated from the table back into the form (and thus removed from the table until being saved again) the page jumps back up to the top.

因此每次用户更新此区域时,他们都有向后滚动,这是一个非常大的形式。我有大部分的部分崩溃,但像我一样,我怀疑用户会在他们向下移动时让他们打开。

So every time a user updates this area, they have to scroll back down, and it's a pretty big form. I have most of the sections in a collapse but like myself I suspect the users will leave them open as they move down.

有谁知道是什么原因造成的,如果有的话有什么简单的方法可以避免它吗?我是jQuery的新手,甚至是JS,我花了大部分时间在服务器端。

Does anyone know what causes this and if there are any really simple ways to avoid it? I'm super new to jQuery, and even JS, having spent most of my time server-side.

编辑:添加HTML:

<div class="scroll">
    <table class="table table-condensed table-striped table-bordered scroll">
        <thead>
            <tr>
                <th>Product</th>
                <th colspan="2">Units</th>
                <th>Pieces</th>
                <th>UOM</th>
                <th>NMFC</th>
                <th>Hazmat</th>
                <th>class</th>
                <th>weight</th>
                <th>L</th>
                <th>W</th>
                <th>H</th>
                <th>Cube</th>
                <th>Density</th>
                <th></th>
                <th></th>
            </tr>
        </thead>
        <tbody id="productTable">
        </tbody>
    </table>
</div>


推荐答案

试试这个

$(SAVE/EDIT).click(function () {

  // your code 

  return false; //add this
});

这篇关于jQuery动态更新字段滚动页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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