使用$ .mobile.changePage()时加载数据的位置 [英] Where to load data when using $.mobile.changePage()

查看:49
本文介绍了使用$ .mobile.changePage()时加载数据的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我正在创建我有2页的移动应用程序

1.登录

2.批准(1。登陆,2。弹出窗口)



我的应用逻辑:

我' m使用批准页面作为登录页面,我从本地存储中检查用户令牌(如果找到)然后加载数据,然后使用$ .mobile.changePage重定向到登录页面()



问题:

我使用$(document).ready()来加载数据,当我得到令牌时,应用程序运行完美。但是当我登录并重定向到Approval页面时,不会调用ready()函数。

Hi friends,
I'm creating mobile application where I have 2 pages
1. Login
2. Approval (1. Landing, 2. Popup)

My logic in application:
I'm using approval page as landing page, where I check the user token from the local storage if found then data is loaded else redirected to Login page using $.mobile.changePage()

Problem:
I have used $(document).ready() to load data, when I get token the application works perfect. But when I Login and get redirected to Approval page the ready() function is not called.

Call on Login successful:
$.mobile.changePage("ApprovalList.html", { changeHash: false, transition: 'slide' });



理解:

当使用AJAX加载页面时,在加载页面之前触发ready(),因此我们应该使用页面事件。



替代方案:

我试过以下


Understanding:
As pages are loaded using AJAX the ready() is fired before the page is loaded, so we should use page events.

Alternative:
I tried following

$(document).on('pageshow', '#divLanding', function () {
                getData('P');
            });



其中getData()具有对WEB API的AJAX调用。



替代方案有问题:

批准页面为2页(登陆,弹出窗口。



登陆页面包含需要批准的请求列表,点击后会打开弹出窗口显示请求的详细信息。



Popup有后退按钮,w重定向到登陆页面。

当我点击后退按钮时,它会进行AJAX调用,因为我正在进行pageshow中的ajax调用。



需要解决方案:

每当我点击后退按钮时,AJAX通话都不应该开启。



任何灵魂或建议?



提前致谢


where getData() has AJAX call to the WEB API.

Problem in alternative:
Approval page as 2 pages (Landing, Popup).

Landing pages has the list of request which needs to be approved, which when clicked opens the Popup displaying the details of the request.

Popup has back button, which redirects to the Landing page.
When I click back button it makes AJAX call, since I'm making ajax call in pageshow.

Solution Needed:
Whenever I click the Back button the AJAX call should not fire.

Any soultion or advise?

Thanks in advance

推荐答案

.mobile.changePage( )



问题:

我用过
.mobile.changePage()

Problem:
I have used


(document).ready()加载数据,当我得到令牌时,应用程序运行完美。但是当我登录并重定向到Approval页面时,不会调用ready()函数。

(document).ready() to load data, when I get token the application works perfect. But when I Login and get redirected to Approval page the ready() function is not called.
Call on Login successful:


。 mobile.changePage(ApprovalList.html,{changeHash:false,transition:'slide'});
.mobile.changePage("ApprovalList.html", { changeHash: false, transition: 'slide' });



理解:

当使用AJAX加载页面时,在加载页面之前会触发ready(),因此我们应该使用页面事件。



替代方案:

我试过以下


Understanding:
As pages are loaded using AJAX the ready() is fired before the page is loaded, so we should use page events.

Alternative:
I tried following


这篇关于使用$ .mobile.changePage()时加载数据的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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