これが私の見解です:
define([
'jquery',
'underscore',
'backbone',
'models/tableModel',
'collections/tablesCollection',
'views/tablesView'
], function($, _, Backbone, tableModel, tablesCollection, tablesView) {
require(['collections/tablesCollection'], function(tablesCollection) {
var t = new tablesCollection(null, {url: 'main-contact'});
var tables = new tablesView({ collection: t, template: 'main-contact-template'});
tables.url = 'main-contact';
return tables; // <!-- returns view, tables can be console.log'ed
});
console.log(tables); // <!-- tables is not defined
});
ステートメントtables
内を取得して、どこにでもアクセスできるようにするにはどうすればよいですか?これは、ビューを返す必要がある場所のようです。そのため、ルートで使用できます。require
console.log
app_router.on('route:index', function(){
require(['views/tables/mainContactView'], function(mainContactView) {
console.log(mainContactView); // <!-- undefined, unless some value is returned from where the console.log() is above
$('#web-leads').html(mainContactView.render().el);
});
});
return 'test'
どこに置いたら、ルートに入れるconsole.log(tables)
ことができます。console.log()
だから私はそこからビューを返す必要があると思います。そのデータを渡すにはどうすればよいですか?今のところ、returnステートメントがあっても、私の見解は未定義です。からビューを取得する必要がありますrequire
。それ、どうやったら出来るの?