javascript - Firefox cannot make an instance of class generated with TypeScript -
i have simple class wrapping grid command have placed within module named components , when test in firefox 14.0.1 i'm getting:
typeerror: components.grid not constructor @http://...
here code generated typescript:
var components; (function (components) { components.griddefaults = { datatype: "json", autowidth: true, rownum: 30, rowlist: [ 10, 20, 30 ], viewrecords: true, sortorder: "asc", pager: "#grid-pager" }; var grid = (function () { function grid(selector, options) { var opts = components.griddefaults; if(options !== undefined && options !== null) { $.extend(opts, options); } this.grid = $(selector).jqgrid(opts); } grid.prototype.settoolbar = function (options) { var pager = this.grid.getgridparam().pager; if(pager !== undefined && pager !== null) { this.grid.navgrid(pager, options); } homecoming this; }; grid.prototype.jqgrid = function () { homecoming this.grid; }; grid.prototype.filter = function (criteria) { this.grid.setgridparam({ page: 1, postdata: criteria }); this.reload(); }; grid.prototype.reload = function () { this.grid.trigger("reloadgrid"); }; homecoming grid; })(); components.grid = grid; })(components || (components = {})); //@ sourcemappingurl=grid-component.js.map
and here line firefox complaining lack of constructor:
var grid = new components.grid("#grid-container", { url: "/home/data", colnames: ['inv no', 'date', 'client', 'amount', 'tax', 'total', 'notes'], colmodel: [ { name: 'id', index: 'id', width: 55 }, { name: 'invdate', index: 'invdate', width: 90, jsonmap: "invdate" }, { name: 'name', index: 'name asc, invdate', width: 100 }, { name: 'amount', index: 'amount', width: 80, align: "right" }, { name: 'tax', index: 'tax', width: 80, align: "right" }, { name: 'total', index: 'total', width: 80, align: "right" }, { name: 'note', index: 'note', width: 150, sortable: false } ], jsonreader: { id: "id", repeatitems: false } });
i hear @typescript team.
i'm not on typescript team, nor have ever used it. not typescript problem, believe. problem you're trying overwrite firefox including native, namely components
.
if changed to
var comps; (function (components) { // maintain local name or alter comps, components.griddefaults = { // ... })(comps || (comps = {})); var grid = new comps.grid("#grid-container", { /* ... */ });
i think work better.
i assume means changing typescript module name. don't know that.
javascript firefox typescript
No comments:
Post a Comment