Ok, I've done some research and after a lot of try, these are my 2 pages:
Custom module for the page with the list of items out of a drupal views
function mymodule_list_menu() {
var items = {};
items['articles'] = {
title: 'Friend\'s list',
page_callback: 'mymodule_list_articles_page'
};
return items;
}
/**
* The page callback to display the view.
*/
function mymodule_list_articles_page() {
try {
var content = {};
content['my_articles_list'] = {
theme: 'view',
format: 'ul',
path: 'my-articles', /* the path to the view in Drupal */
row_callback: 'mymodule_list_articles_list_row',
empty_callback: 'mymodule_list_articles_list_empty',
attributes: {
id: 'my_articles_list_view'
}
};
return content;
}
catch (error) { console.log('mymodule_list_articles_page - ' + error); }
}
/**
* The row callback to render a single row.
*/
function mymodule_list_articles_list_row(view, row, variables) {
try {
if (row.immagine.indexOf('http') > -1){
img = {
my_custom_image:{
theme:'image',
path:row.immagine,
alt:'gift',
title:'gift'
}
};
img1 = row.immagine;
}else{
var image_html = theme('image', { path: row.immagine.src });
img = image_html;
img1 = "---";
}
var title_html = row.nome+" "+row.cognome.charAt(0)+"."+" "+row.title;
var image_html = theme('image', { path: row.img.src });
var link = l('' + title_html + image_html, 'singlegiftapp/' + row.nid);
return link;
}
catch (error) { console.log('mymodule_list_articles_list_row - ' + error); }
}
function mymodule_list_articles_list_empty(view, variables) {
return t('Sorry, no articles were found.');
}
Custom module for the page with the single item after clicking one in the previuos list and that call another drupal views
function mymodule_single_menu() {
var items = {};
items['singlegiftapp/%'] = {
page_callback: 'mymodule_single_page',
pageshow: 'mymodule_single_pageshow',
page_arguments: [1]
};
return items;
}
function mymodule_single_callback(callback, nid) {
node_load(nid, {
success: function(node) {
callback.call(null, node.title);
}
});
}
function mymodule_single_container_id(nid) {
return 'gift-' + nid;
}
function mymodule_single_page(nid) {
var content = {};
content['divname'] = {
theme: 'jqm_item_list',
title: '',
items: [],
attributes: { id: 'divname' }
};
return content;
}
function mymodule_single_pageshow(nid) {
var path_to_view = 'singlegiftapp/'+nid;
views_datasource_get_view_result(path_to_view, {
'success':function(data){
if (data.nodes.length > 0) {
var items = [];
$.each(data.nodes, function(index, object){
var row = object.node;
var image_html = theme('image', { path: row.img.src });
var description =
'<h1>' + row.title + '</h1>' +
'<p> ' + row.field_anothertext+ '</p>';
var dato = t(description+image_html);
items.push(dato);
});
drupalgap_item_list_populate("#divname", items);
}
}
});
}
These 2 module are working for me based on my views. Hope that would help to someone...