使用jQuery Mobile更新URL字符串&刷新.load

时间:2012-08-16 20:58:57

标签: jquery ajax mobile jquery-mobile cordova

我正在使用PhoneGap& jQuery mobile构建本机应用程序。大多数应用程序都存在于webview中,但标题,导航和放大除外。页脚。我在webview中有一个文章链接列表以及一个分页链接。当用户点击文章链接时,新页面将加载到现有的webview中,这正是我想要的,但是分页链接会给我一个jquery移动加载错误。

基本上我想要做的是将分页URL附加到当前webview URL的末尾,例如:

  • 当前的网络视图网址为:m.example.com/?mode = Native;
  • 用户点击分页链接(href =“2 /”),网页视图更新为:m.example.com/2/?mode=Native

javascript看起来像这样:

// loads first page into webview    
var mobPage = 'http://m.example.com/?mode=Native';

$('#content').load(mobPage, function() {
    $('#content').fadeIn(500);
});

// to load additional pages into webview
$('#articles a, #paginate a').live('click', function(){
    event.preventDefault();
    var nextPage = $(this).attr('href');
    var mobPage = nextPage+"?mode=Native";
    $('#content').load(mobPage);
});

这样做的正确方法是什么?

0 个答案:

没有答案