【问题标题】:Sencha phonegap JSON request (with WordPress backend) returning only 5 itemsSencha phonegap JSON 请求(带有 WordPress 后端)仅返回 5 个项目
【发布时间】:2014-05-02 15:38:50
【问题描述】:

我正在使用 sencha-touch 2 和 phonegap 创建一个应用程序。该应用程序适用于在线报纸。我有一个存储文章的 jsonp 请求。 JSON 请求来自使用 JSON API 的 WordPress。当我在网络浏览器上查看应用程序时,文章的数量是正确的,但是当我在 android 手机上构建它时,无论我在请求中输入的“计数”参数如何,都只出现 5 篇文章。

这是我的 ArticleList.js(其中包括一段静态信息)

Ext.define('Commentator.store.Article', {
  extend: 'Ext.data.Store',
  requires: [
    'Commentator.model.Article',
    'Ext.data.proxy.JsonP'
  ],  
  config: {
    storeId: 'ArticleStore',
    autoLoad: false,
    model: 'Commentator.model.Article',
    proxy: {
      timeout: 3000,
      type: 'jsonp',
      url: 'http://[site]/?json=get_category_posts?id=features&post_status=publish',
      reader: {
        type: 'json',
        rootProperty: 'posts'
      }
    }
  }
});

这是我的 Main.js

Ext.define('Commentator.controller.Main', {
  extend: 'Ext.app.Controller',

  config: {
    refs: {
      list: 'articles',
      side_list: 'side_menu',
      navBtn : 'button[name="burgerButton]',
      topbar: 'TopBar'
    },
    control: {
      list: {
        onDataRefresh: 'updateList',
        tap: 'updateList'
      },
      topbar: {
        initialize: 'swipeBar'
      }
    }
  },

  swipeBar: function(evt) {
      evt.element.on({
        swipe: function(e, node, options){
          if (Ext.Viewport.getMenus().left._hidden) {
            if(e.direction == "right") {
              Ext.Viewport.showMenu("left");
            }
          } else {
            Ext.Viewport.hideMenu("left");
          }
        }
      });
  },
  updateList: function() {
    console.log(this.getList());
  },

  //called when the Application is launched, remove if not needed
  launch: function(app) {
   Ext.getStore("ArticleStore").load(function(records, options, success) {
     console.log(records);
      if(!success) {
        for(var i = 0; i < 5; i++) {
          console.log("errror");
          Ext.getStore("ArticleStore").load();
        }
      }
    });
      Commentator.view.SubNavigation.setMenu();
    //});
  }

});

Article.js(商店)

Ext.define('Commentator.store.Article', {
  extend: 'Ext.data.Store',
  requires: [
    'Commentator.model.Article',
    'Ext.data.proxy.JsonP'
  ],  
  config: {
    storeId: 'ArticleStore',
    autoLoad: false,
    model: 'Commentator.model.Article',
    proxy: {
      timeout: 3000,
      type: 'jsonp',
      url: 'http://[site]/?json=get_category_posts?id=features&post_status=publish',
      reader: {
        type: 'json',
        rootProperty: 'posts'
      }
    }
  }
});

【问题讨论】:

    标签: android wordpress cordova sencha-touch jsonp


    【解决方案1】:

    我找到了解决我们问题的方法。这是 WordPress JSON API 的问题。我们切换到 Thermal API,现在它可以完美运行了。

    【讨论】:

      猜你喜欢
      • 2015-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多