backbone.js - How can i create object of 'Todo' model in b.js which is in another javascript file a.js -


in a.js

var todo = backbone.model.extend({     idattribute: "_id",     defaults: {         _id: '',         label: '',     }, }); 

in b.js

$(function(){     $.getscript("/js/a.js");     var obj = new todo(); }); 

it giving error problem not constructor

i believe getscript asynchronous call todo not available, resolve issue call todo constructor in getscript success callback:

$(function(){     $.getscript("/js/a.js", function() {         var obj = new todo();     }); }); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -