Closed (works as designed)
Project:
DrupalGap
Version:
7.x-1.8
Component:
Mobile Application Development Kit Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Jan 2015 at 05:54 UTC
Updated:
12 Jan 2015 at 06:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tyler.frankenstein commentedPlease share your entire function that loads the nodes when the app starts. Particularly, I'm interested in what hook(s) you're using to accomplish this.
Comment #2
info@cgfix.com commented/*
tcw_cabo_cache_all() run from tcw_cabo_cach_nodes() below
*/
function tcw_cabo_cach_nodes(){
//load all node id's
var path_to_view = 'drupalgap/views_datasource/drupalgap_content';
var node_ids = []
views_datasource_get_view_result(path_to_view, {
'success':function(data){
$.each(data.nodes, function(index, object){
node_ids.push( object.node.nid );
});
}
});
// loop through each nid
for( nid in node_ids ){
//load nodes into cache
//first attempt, runs - pages still not loading offline
/* node_load(nid, {
success: function(node) {
console.log("Node Loaded " + node.title);
console.log(node);
}
}); */
//second attempt - pages still not loading offline
/* drupalgap_goto('node/'+nid); */
//third attempt - - pages still not loading offline
node_page_view_pageshow(nid);
}
}
/*
tcw_cabo_cache_all() run on deviceready or deviceinstall
*/
function tcw_cabo_cache_all(){
tcw_cabo_events_pageshow(); //works
tcw_cabo_locations_pageshow(); //works
tcw_cabo_info_pageshow(); //works
tcw_cabo_cach_nodes(); //runs but pages don't load offline
tcw_cabo_cach_vocab(); //runs but pages don't load offline
tcw_cabo_cach_terms(); //runs but pages don't load offline
}
Comment #3
info@cgfix.com commentedattached is the entire module I wrote if you want to see it all together
Comment #4
info@cgfix.com commentedAfter studying the source code trail from node_load vs drupalgap_got(), I am starting to wonder if the problem maybe that even though I have loaded all the nodes into cache, they are not associated with any page callbacks and so then calling drupalgap_got() later does not find the it in cache and trys to load it from server?
Comment #5
tyler.frankenstein commentedIf you have caching enabled in settings.js, and you call node_load() (or any entity loader function, you don't need to call entity_load()), the system will automatically place that entity into local storage once it is retrieved from the server. Anytime afterwards, when node_load() is called (even while building a page), the system will pull that node out of local storage.
Comment #6
info@cgfix.com commentedscratch that, I see whats happening. There is a variable 'content' that is created and added to the node object in cache probably when the page is rendered. I think I just need to know what function does that so I can cache it.
Comment #7
tyler.frankenstein commentedYes, the entity_services_request_pre_postprocess_alter() function in the SDK handles rendering the content when the entity comes back from the server, and attaches it to the
contentvariable: https://github.com/signalpoint/DrupalGap/blob/7.x-1.x/src/modules/entity...Then entity_load() handles saving the entity to local storage: https://github.com/easystreet3/jDrupal/blob/7.x-1.x/src/entity.js#L55
At one time I know the entity was saved to local storage before the content was rendered, so when loading it from local storage, it would appear to have empty content. I thought I fixed that though, so it would be saved to local storage after the content was rendered.
Will you please confirm if, or if not, the entity's content is attached to it when loading an entity from local storage?
Comment #8
info@cgfix.com commentedI think I solved it. This seems to work.
node_load(nid, {
success: function(node) {
console.log("Node Loaded " + node.title);
drupalgap_entity_render_content('node', node);
// console.log(node);
}
});
Comment #9
info@cgfix.com commentedI am using version 7.x-1.8. In this version, entity_load does not render the content.
Comment #10
tyler.frankenstein commented