简体   繁体   English

检索新页面时,jQuery Mobile与函数冲突

[英]jquery mobile conflict with a function when a new page is retrieved

I have a form for users to login to the site and have placed it in the main menu with opacity set to zero. 我有一个供用户登录该网站的表单,并将其放在不透明度设置为零的主菜单中。 when a user clicks on login he would be supposed to see the form with performing the function below: 当用户单击登录名时,应该可以看到执行以下功能的表单:

$("#login-form-show").click(function(){
    $("form.hidden").animate({opacity:1},400);
}); 

and the form itself has a button which will call a function to hide the form again as below: 表单本身具有一个按钮,该按钮将调用一个函数以再次隐藏表单,如下所示:

$("#form-close-button").click(function(){
    $("form.hidden").animate({opacity:0},400);
});

it works in the first page and all the pages if they start to load by the user, but the problem is that when the jqueryMobile retrieves the page with its default "pagination" or "method of page loading" which uses ajax, the above functions wouldn't work. 它可以在第一页和所有页面(如果它们开始由用户加载)中工作,但是问题是,当jqueryMobile使用默认的“分页”或“页面加载方法”(使用ajax)检索该页面时,上述功能不会工作。 (the user has to reload the page to access the form). (用户必须重新加载页面才能访问表单)。 Note that I have called the script in all pages and on my logic, it should work. 请注意,我已经在所有页面中调用了该脚本,并且按照我的逻辑,它应该可以工作。

Also note that I am using php, purecss, jquery, jqueryMobile. 另请注意,我正在使用php,purecss,jquery,jqueryMobile。

you can see the problem in this url: www.obpchap.com 您可以在以下网址中看到问题:www.obpchap.com

The problem is, that after changing the page, the element with the id "login-form-show" exists twice in the DOM: 问题是,更改页面后,标识为“ login-form-show”的元素在DOM中存在两次: 在此处输入图片说明

I do not know, how you can replace the old page with the new page using jQuery mobile. 我不知道如何使用jQuery mobile将旧页面替换为新页面。 But you should aim for that. 但是你应该为此而努力。

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

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