سؤال

I am creating an app using sencha-touch 2 and phonegap. The app is for an online newspaper. I have a jsonp request for the store of articles. The JSON request is from WordPress using the JSON API. When I view the app on a web browser the number of articles is correct but when I build it on the android phone only 5 articles appear, no matter the "count" parameter I input into the request.

Here is my ArticleList.js (which includes a piece of static information)

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'
      }
    }
  }
});

Here is my 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 (the store)

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'
      }
    }
  }
});
هل كانت مفيدة؟

المحلول

I found the solution to our problem. It was a problem with the WordPress JSON API. We switched over to Thermal API and now it works perfectly.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top