Fehler definiert:Uncaught Reference: myClass nicht
Uncaught ReferenceError: Jtable is not defined
Ich versuche, meine eigene Klasse Jtable
genannt zu verwenden, ich weiß nicht, was ich falsch mache, kann mir jemand helfen?
Das ist mein file1 Code:
(function() {
var Jtable;
Jtable = (function() {
function Jtable(cols) {
this.cols = cols;
}
Jtable.prototype.create_header = function() {
var table, tr;
tr = create_header_row();
return table = $('<table>').append(tr);
};
Jtable.prototype.create_header_row = function() {
var tr;
tr = $('<tr>');
$.each(this.cols, function(key, value) {
var th;
th = $('<th>').append(value);
return tr.append(th);
});
return tr;
};
return Jtable;
})();
}).call(this);
Das ist mein file2 Code:
$(function() {
var cols = ['col-1', 'col-2', 'col-3'];
var table = new Jtable(cols);
});
UPDATE 1:
Hier sind meine Skripte:
<!-- scripts -->
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script src="file1.js"></script>
<script src="file2.js"></script>
Ihre beschriebene 'JTable' ist in diesem Kontext nicht verfügbar, da sie im IIFE beschrieben ist. –