【问题标题】:Second page does not redirect to the specific link第二页不重定向到特定链接
【发布时间】:2019-02-07 16:30:06
【问题描述】:

我的 Jquery 代码由以下代码组成

$('.readControl').click(function() {
                doSubmitPostActions();
                var path = this.id;
                $(location).attr('href', path);
            });

在我的 index.jsp 中,这是调用 readControl 类的文件

    <tr id="${item.employee.id}">
    <td>
 <a class="readControl" id="${item.path}" href="#"> ${item.employee.dateControl} </a>
 </td>
    </tr>

我的查询是我在此日期控制部分中有 12 个元素,前 10 个表将我重定向到 href 标记,但在 10 个元素之后它没有。是分页问题还是我们需要在 Jquery 部分进行更改?如果是,代码中有哪些必要的更改?

【问题讨论】:

  • 大声思考:会不会是“下一页”不涉及页面重新加载?如果是这样,你是否再次绑定点击事件?根据您所描述的行为,这件作品似乎丢失了。
  • 我是初学者,能否提供一个示例代码

标签: jquery spring-boot jsp pagination


【解决方案1】:

你的JSP代码应该如下

 <tr id="${item.employee.id}">
        <td>
     <a class="readControl" id="${item.path}" href="#" onclick="javascript:redirectToReadControl(this.id)"> ${item.employee.dateControl} </a>
     </td>
        </tr>

您的 Jquery 代码应在 onload 函数之外替换为以下内容

 function redirectToReadControl(path){
                doSubmitPostActions();
                $(location).attr('href', path);
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-18
    • 1970-01-01
    • 2020-09-11
    • 2015-06-19
    • 1970-01-01
    • 2018-01-15
    • 1970-01-01
    相关资源
    最近更新 更多