How to properly use a JS library that inserts content into existing DIV? As with many JS libs i need an existing DIV for the lib to insert its content. I am trying to use the Chart.js library to inset a chart on a custom drupalgap page.

I eventually discovered the menu item page handlers and did this:

items['qleva_start_auth'] = {
  title: 'Home Auth',
  page_callback: 'qleva_start_auth',
  pageshow: 'qleva_start_auth_show',
};


in my hook_menu.

qleva_start_auth now only has the required empty DOM element:

function qleva_start_auth() {
  var content = {};
  content['my_stuff'] = {
    markup: '&lt;canvas id="myChart" width="100" height="100"&gt;&lt;/canvas&gt;'
  };
  return content;
}


and the pageshow callback has the code to set up the chart.

This seems to work great except that my chart is now on every page; added to the bottom of the content for that page. 

What am i doing wrong?
You can likely use drupalgap_add_js() at the beginning of your pageshow implementation to add the Chart.js library:

function qleva_start_auth() {
  drupalgap_add_js('Chart.js');
  // ...
}