javascript - Google.Load ['table'] does nothing in Chrome content-script -
i creating chrome extension
utilises content-script
insert google visualisation table page once has finished loading. problem though table never displayed - not in html can seen images below.
manifest.json
{ "manifest_version": 2, "name": "blah", "version": "1.0", "permissions": [ "tabs", "http://*/*" ], "web_accessible_resources": [ "jquery-1.10.2.min.js", "jquery-1.10.2.min.map" ], "content_scripts": [ { "matches": ["http://*.ebay.co.uk/*"], "js": ["jquery-1.10.2.min.js", "jsapi.js", "myscript.js"], "run_at": "document_end" }] }
myscript.js
$('#cbrt').after('<div id=\'google_table_div\'></div>'); google.load('visualization', '1', { packages:['table'], callback : function() { drawtable(); } }); function drawtable() { alert('draw'); var data = new google.visualization.datatable(); data.addcolumn('string', 'name'); data.addcolumn('number', 'salary'); data.addcolumn('boolean', 'full time employee'); data.addrows([ ['mike', {v: 10000, f: '$10,000'}, true], ['jim', {v:8000, f: '$8,000'}, false], ['alice', {v: 12500, f: '$12,500'}, true], ['bob', {v: 7000, f: '$7,000'}, true] ]); var table = new google.visualization.table(document.getelementbyid('google_table_div')); table.draw(data, {showrownumber: true}); }
the alert
in callback never happens. here html @ end:
you need load 'table' package well. so:
packages:['corechart', 'table']
Comments
Post a Comment