我有一個使用文本插件優化的RequireJS設置。我似乎遇到了被添加到我的模塊中的'.js'文件名。我正在看這在Firefox 17.RequireJS文本插件添加'.js'到文件名,但在同一個域上
我閱讀了這個項目,但我很確定我所有的文件都在同一個域。 Why is requirejs trying to append a '.js' to .jst template files that are loaded with the !text plugin?
我的文件在位於
- dev-img4.x.com/m/j/mains/main-article.js
- dev-img4.x.com/m/焦耳/視圖/ logged_out.js
- dev-img4.x.com/m/j/views/templates/logged_out.html
文本插件試圖尋找dev-img4.x.com/ m/j/views/templates/logged_out.html.js,這對我沒有意義,因爲它l ooks像我所有的依賴都在同一個域上。我不確定文本插件如何認爲存在跨域問題。
主article.js
require.config({
baseUrl: 'dev.x.com/m/j',
paths: {
'jquery': 'dev.x.com/m/j/lib/jquery',
'backbone': 'dev.x.com/m/j/lib/backbone',
'underscore': 'dev.x.com/m/j/lib/underscore',
'text': 'dev.x.com/m/j/lib/text'
},
shim: {
'underscore': {
exports: '_'
},
'backbone': {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
}
},
urlArgs: 'buildlife=1',
waitSeconds: 15
});
require(['jquery', 'modules/site', 'underscore', 'backbone', 'views/logged_out'], function($, site, _, Backbone, loggedOutView) {
//This function will be called when all the dependencies
//listed above are loaded. Note that this function could
//be called before the page is loaded.
//This callback is optional.
var loggedOutBar = new loggedOutView();
/* Initialize code */
$(document).ready(function() {
/* sitewide code */
site.init();
$('.rslogo').after(loggedOutBar.render());
});
}
);
logged_out.js
define(['module', 'jquery', 'underscore', 'backbone', 'text!views/templates/logged_out.html'], function(module, $, _, Backbone, loggedOutTemplate) {
/* Create a view of the logged out bar */
var loggedOutView = Backbone.View.extend({
className: 'loginbar',
initialize: function() {
},
template: _.template(loggedOutTemplate),
render: function() {
this.$el.html(this.template);
return this; /* Allow method chaining after render */
}
});
return loggedOutView;
});
logged_out.html
<a href="#" class="signin">Sign In</a> | <a href="#" class="signup">Sign Up</a>
沒有www.dev.x.com域名,所以我會嘗試相對路徑。謝謝。 – Stephen 2013-02-25 01:50:53
我無法使用相對路徑。我有一個奇怪的服務器設置,我無法控制/ j目錄不直接脫離域名。 :( – Stephen 2013-02-25 03:05:18