如何让我的事件在所有可数据页面上运行?

时间:2018-03-01 06:52:38

标签: jquery pagination datatables onclick

在我的数据表加载后点击const PrivateRoute = ({ component: Component, exact, strict, path, ...rest }) => ( <Route exact={exact} strict={strict} path={path} render={props => fakeAuth.isAuthenticated ? ( <Component {...props} {...rest} /> ) : ( <Redirect to={{ pathname: "/login", state: { from: props.location } }} /> ) } /> ); ,然后我收到提醒。但这仅适用于数据表分页的第一页。如果我去另一个页面它就不再工作了。

.mytext

1 个答案:

答案 0 :(得分:2)

您应该使用事件delegationhttp://api.jquery.com/on/)。您可以绑定document或“父元素”,而不是直接绑定在元素上,然后设置target

以下是一个例子:

$(document).on("click", ".mytext", function () {
    alert("something happens");
});