Hello again! after some time without theming on javascript drupalgap, i was asked to made some changes on my application. For example i have a form and an ul, in the form i could add a title at the start with this code:

form.prefix = '<h2>BUSCADOR</h2>';

But now i want to do the same with the ul made with this code:

var content = {};
    content['listado_de_informes'] = {
      theme: 'view',
      pager_pos: 'bottom',
      format: 'ul',
      path: 'drupalgap/listado-de-informes',
      row_callback: 'my_module5_informes_row',
      empty_callback: 'my_module5_informes_empty',
      attributes: {
        id: 'listado_de_informes_view'
      }
    };
    return content;

The problem i have is that if i add a markup on the code the content dissapears.
Is any way to put the markup in the same div as the ul like a prefix?

Example:

TITLE (that's what i am missing)
List:
item1
item2
item3
Thanks in advance!!!

Comments

HomerO created an issue. See original summary.

tyler.frankenstein’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Module Code » Mobile Application Development Kit Code
Category: Plan » Support request
Status: Active » Postponed (maintainer needs more info)

Have you tried putting a title on the Views Render Array? For example:

content['listado_de_informes'] = {
      theme: 'view',
      title: t('Listado de informes'),
      title_attributes: {
        class: 'foo'
      },
      /* ... */
    };
HomerO’s picture

Tried that but it puts the title con top of the page, i have set a title on top of the form, what i try to achieve is to put another after de form and before the ul li.

HomerO’s picture

This is my full module code, if you need it. I need to put the title/markup before the first row of the ul render, tried using the array but it puts on top of the page.

function my_module5_menu() {
  var items = {};
  items['informes'] = {
    title: 'Informes',
    page_callback: 'my_module5_informes_page'
  };
  return items;
}
/**
 * The page callback to display the view.
 */
function my_module5_informes_page() {
  try {
    var content = {};
    content['listado_de_informes'] = {
      theme: 'view',
      pager_pos: 'bottom',
      format: 'ul',
      path: 'drupalgap/listado-de-informes', /* the path to the view in Drupal */
      row_callback: 'my_module5_informes_row',
      empty_callback: 'my_module5_informes_empty',
      attributes: {
        id: 'listado_de_informes_view'
      }
    };
    return content;
  }
  catch (error) { console.log('my_module5_informes_page - ' + error); }
}


/**
 * The row callback to render a single row.
 */
function my_module5_informes_row(view, row) {
  try {
    return l('<p>'+ row.title +'</p>', 'node/' + row.nid);
  }
  catch (error) { console.log('my_module5_informes_row - ' + error); }
}
tyler.frankenstein’s picture

You could try checking the row._position value for when it is 0, and then you could put something immediately before the first list item, although it'd be inside the list itself though.

var html = '';
if (row._position == 0) {
  html += 'title goes here'
}
html += 'other stuff here';
return html;